【发布时间】:2018-04-03 20:24:29
【问题描述】:
我有一个以本地时间格式显示时间的文本框 - 04/03/2018 02:59:44 PM 我在 python 中使用 Selenium 来获取这个时间并将其(本地时间)转换为纪元时间(UCT)。但它正在转换为早 11 小时 30 分钟的时间(2018 年 4 月 3 日凌晨 3:29:44)。这是我的代码:
next_chk_dt = myDriver.find_element_by_xpath("(//input[@id='dateIDVisible'])[6]").get_attribute('value')
# displays 04/03/2018 02:59:44 PM if you print the value
temp_Time2 = datetime.datetime.strptime(next_chk_dt, '%m/%d/%Y %H:%M:%S %p')
epoch_Time1 = calendar.timegm(temp_Time2.timetuple())
print (epoch_Time1)
# You get 1522726184, which is incorrect. it should be 1522781984
【问题讨论】:
-
您当地的时区是?
-
我的时区是美国东部时间