开发者

How to format time and convert to gmt time?

I have a date string in the format of 3/29/2010. Can someone tell开发者_如何学编程 me how to convert it to GMT time?


This very suspiciously appears that you are trying to correct something for daylight savings time, which is not really something you should be doing manually.

You should review the datetime documentation, and specifically the portions related to using time zones.


if (timeH,timeM)>(2,0): # if it is after 2 am
    timeH1=timeH+5
    if timeH1>=24:#deduct 24 hrs whenever it's over 24
        timeH1=timeH1-24
else:
    timeH1=timeH+4

could be changed to: timeH1 = (timeH + 5) % 24

and you also need to check the other case and subtract 24 which you aren't doing now

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜