codepython 2018-05-22
最近写python,遇到了一个问题,需要获取当日凌晨零点的时间戳,网上实在没有找到,自己手写了一个,有点挫
# -*- coding:utf-8 -*- import time now_time = int(time.time()) day_time = now_time - now_time % 86400 + time.timezone day_time_str = time.asctime(time.localtime(day_time)) print day_time print day_time_str import datetime today = datetime.date.today() today_time = int(time.mktime(today.timetuple())) print today_time
输出如下:
1518105600
Fri Feb 9 00:00:00 2018
1518105600