我对 dateformat 有一些疑问Tue Feb 25 2014 00:00:00 GMT+0530 (IST)
。
- 确实
Tue Feb 25 2014 00:00:00
意味着GMT
或IST
- 是否可以将其转换为 python
datetime
。 - 是否可以将其转换为
DD-MM-YY,HH:MM:SS
GMT 格式。
这是我试图转换为python datetime
::
但是当我尝试使用时出现错误%z
:
>>> time_format="%a %b %d %Y %H:%M:%S GMT%z (%Z)"
>>> v="Tue Feb 25 2014 00:00:00 GMT+0530 (IST)"
>>> mydate=datetime.strptime(v,time_format)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/_strptime.py", line 317, in _strptime
(bad_directive, format))
ValueError: 'z' is a bad directive in format '%a %b %d %Y %H:%M:%S GMT%z (%Z)'
但这有效:
>>> time_format="%a %b %d %Y %H:%M:%S GMT (%Z)"
>>> v="Tue Feb 25 2014 00:00:00 GMT (IST)"
>>> datetime.strptime(v,time_format)
datetime.datetime(2014, 2, 25, 0, 0)
但还是什么都不懂TIMEZONE
。