I see a lot on converting a date string to an datetime
object in Python, but I want to go the other way.
I've got
datetime.datetime(2012, 2, 23, 0, 0)
and I would like to convert it to string like '2/23/2012'
.
datetimepython
I see a lot on converting a date string to an datetime
object in Python, but I want to go the other way.
I've got
datetime.datetime(2012, 2, 23, 0, 0)
and I would like to convert it to string like '2/23/2012'
.
Best Answer
You can use strftime to help you format your date.
E.g.,
will yield:
More information about formatting see here