How to format time and convert to gmt time?

I have a date string in the format of 03/29/2010. Can someone tell me how to convert it to GMT?

0
python time
source share
2 answers

It very suspiciously seems that you are trying to fix something for daylight saving time, which is actually not what you have to do manually.

You should look at the datetime documentation and, in particular, the parts related to using time zones .

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

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

and you also need to check another case and subtract 24 that you are not doing right now.

+1
source share

All Articles