time_str = "2016-08-09 16:07:31"
dtime = time.mktime(time.strptime(time_str, '%Y-%m-%d %H:%M:%S'))
拿到datetime对象:
dtime = datetime.datetime.utcfromtimestamp(float(dtime))
处理时差问题:
(dtime + datetime.timedelta(hours=16)).strftime('%Y-%m-%d %H:%M:%S')
def time_to_name_day():
time_now = time_to_name_str(time.time())
local_time = time.localtime(time_now)
return time.strftime('%Y%m%d', local_time)