Reputation: 303
I have this string '2015-04-08T07:52:00Z'
and I wanna to convert it to '08/04/2015'
, how can I do this?
Upvotes: 7
Views: 8824
Reputation: 4455
You can use easy_date to make it easy:
import date_converter
converted_date = date_converter.string_to_string('2015-04-08T07:52:00Z', '%Y-%m-%dT%H:%M:%SZ', '%d/%m/%Y')
Upvotes: 1
Reputation: 4926
You can use the datetime.datetime.strptime()
function to create a datetime object, then datetime.datetime.strftime()
to return your correctly formatted date like so:
from datetime import datetime
dt = datetime.strptime('2015-04-08T07:52:00Z', '%Y-%m-%dT%H:%M:%SZ')
print dt.strftime('%d/%m/%Y')
Upvotes: 10