Back
I can see a lot of changing over a date string to a DateTime object in Python, however I need to go the alternate way.
I have
datetime.datetime(2012, 2, 23, 0, 0)
also, I might want to change it over to string like '2/23/2012'.
Try using strftime, which will help you to format your date
For example:
import datetimet = datetime.datetime(2012, 2, 23, 0, 0)t.strftime('%m/%d/%Y')
import datetime
t = datetime.datetime(2012, 2, 23, 0, 0)
t.strftime('%m/%d/%Y')
output:
'02/23/2012'
Click on this link for more information.
Interested to learn python in detail? Come and Join the python course.
31k questions
32.8k answers
501 comments
693 users