Python: How to get UTC time given TIMEZONE
问题 I am in the US and I want to get the UTC time (without the effect of Daylight Saving Time) for a piece of code: localtime = strftime("%m%d%y%H%M", gmtime()) Right now that code give me time in Greenwich, England. I know that I have a time offset of -8 (GMT -8). How can I get the UTC time to a specific timezone? (using Python library, not casting the hour to integer, - 8, and than convert it back) Thank you. 回答1: Try the datetime module: datetime.datetime.utcnow() + datetime.timedelta(hours=-8