如何将GST时间戳转换为纪元

时间:2019-05-10 09:27:09

标签: python time

我想使用python将本地时间戳(GST)转换为Epoch

我的尝试:-

import calendar
from time import strptime, strftime, mktime, gmtime
import time
f=time.mktime(time.strptime('Monday, April 10, 2017 12:00 PM GST', '%A, %B %d, %Y %H:%M %p %Z'))
print int(f)

得到错误:-

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    f=time.mktime(time.strptime('Monday, April 10, 2017 12:00 PM GST', '%A, %B %d, %Y %H:%M %p %Z'))
  File "/usr/lib/python2.7/_strptime.py", line 478, in _strptime_time
    return _strptime(data_string, format)[0]
  File "/usr/lib/python2.7/_strptime.py", line 332, in _strptime
    (data_string, format))
ValueError: time data 'Monday, April 10, 2017 12:00 PM GST' does not match format '%A, %B %d, %Y %H:%M %p %Z'

0 个答案:

没有答案