开发者

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 to format. This is equivalent to datetime(*(time.strptime(date_string, format)[0:6])). ValueError is raised if the date_string and format can’t be parsed by time.strptime() or if it returns a value which isn’t a time tuple. See section strftime() and strptime() Behavior.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜