utc格林时间==》东八区北京时间
原始日期格式:
utctime = ‘2016-07-26 10:08:29’
localtime = (datetime.datetime.fromtimestamp(time.mktime(time.strptime(utctime,‘%Y-%m-%d %H:%M:%S‘))) + datetime.timedelta(hours = 8)).strftime("%Y-%m-%d %H:%M:%S")
转换后日期格式:2016-07-26 18:08:29
北京时间转换成UTC时间:
localtime = ‘2016-07-26 10:08:29’
utctime = datetime.datetime.utcfromtimestamp(time.mktime(time.strptime(localtime,‘%Y-%m-%d %H:%M:%S‘)))
转换后:2016-07-26 02:08:29
时间: 2024-10-14 07:38:39