Converting a string to a formatted date-time string using Python
For datetime
objects, strptime
is a static method of the datetime
class, not a free function in the datetime
module:
>>> import datetime>>> s = datetime.datetime.strptime("20091229050936", "%Y%m%d%H%M%S")>>> print s.strftime('%H:%M %d %B %Y (UTC)')05:09 29 December 2009 (UTC)