import time tmstm = '2018121810' timeArray = time.strptime(tmstm, "%Y%m%d%H") # print(timeArray) print(int(time.mktime(timeArray))) import datetime,time nowutcdatetime = datetime.datetime.utcnow() un_time = time.mktime(nowutcdatetime.timetuple()) print(un_time) # utc时间 # print(datetime.datetime.fromtimestamp(1545868858)) # dtimeArray = time.strftime(nowutc) # utc转换时间 # timenow = (datetime.datetime.utcnow() + datetime.timedelta(hours=8)) # print(timenow)