A string is returned
July 5, 2010
A string is returned
July 5, 2010
You can use the datetime
module for working with dates and times in Python. The strftime
method allows you to produce string representation of dates and times with a format you specify.
>>> import datetime
>>> datetime.date.today().strftime("%B %d, %Y")
'July 23, 2010'
>>> datetime.datetime.now().strftime("%I:%M%p on %B %d, %Y")
'10:36AM on July 23, 2010'
>>> import datetime
>>> now = datetime.datetime.now()
>>> now.strftime("%B %d, %Y")
'July 23, 2010'