Converting Python String to Date
I need to convert th开发者_如何转开发e Python string "Mon Aug 29 2011 18:30:00 GMT+0530 (IST)" into "20110829T183000Z" and "20110829T173000Z" (Date + 1 hour).
Never have been good at remembering datetime APIs, would appreciate the help here!
google it. increasing your google skills is always better than being lazy.
http://docs.python.org/library/datetime.html#datetime.datetime.strptime
classmethod
datetime.strptime(date_string, format)
Return a datetime corresponding to
date_string
, parsed according toformat
. This is equivalent todatetime(*(time.strptime(date_string, format)[0:6]))
.ValueError
is raised if thedate_string
andformat
can’t be parsed bytime.strptime()
or if it returns a value which isn’t a time tuple. See sectionstrftime()
andstrptime()
Behavior.
精彩评论