作者:大头莎LALA | 来源:互联网 | 2023-08-04 14:34
Heyall!Ivegottimezonetroubles.大家好!我遇到了时区问题。Ihaveatimestampof2010-07-2623:35:03我的时间戳
Hey all! Ive got timezone troubles.
大家好!我遇到了时区问题。
I have a time stamp of 2010-07-26 23:35:03
我的时间戳是2010-07-26 23:35:03
What I really want to do is subtract 15 minutes from that time.
我真正想做的是从那时起减去15分钟。
My method was going to be a simple conversion to unix time, subtract the seconds and convert back. Simple right?
我的方法是简单转换为unix时间,减去秒数并转换回来。简单吧?
My problem is that python adjusts the returned unix time using my local timezone, currently eastern daylight savings time which I believe is GMT -4.
我的问题是python使用我的本地时区调整返回的unix时间,目前东部夏令时我认为是GMT -4。
So when I do this:
所以当我这样做时:
# packet[20] holds the time stamp
unix_time_value = (mktime(packet[20].timetuple()))
I get 1280201703 which is Tue, 27 Jul 2010 03:35:03. I can do this:
我得到1280201703,这是星期二,2010年7月27日03:35:03。我可以做这个:
unix_time_value = (mktime(packet[20].timetuple())) - (4 * 3600)
but now I have to check for eastern standard time which is -5 GMT and adjust the (4 * 3600) to (5 * 3600). Is there any way to tell python to not use my local timezone and just convert the darn timestamp OR is there an easy way to take packet[20] and subtract 15 minutes?
但现在我必须检查东部标准时间-5 GMT并将(4 * 3600)调整为(5 * 3600)。有没有办法告诉python不使用我的本地时区只是转换darn时间戳或有一个简单的方法来采取数据包[20]并减去15分钟?
3 个解决方案