python - 根据日期获取当天凌晨时间
程序员文章站
2024-01-06 09:41:22
...
# codingutf-8
import datetime
def get_day_zero_time(date):
"""根据日期获取当天凌晨时间"""
if not date:
return 0
date_zero = datetime.datetime.now().replace(year=date.year, month=date.month,
day=date.day, hour=0, minute=0, second=0)
date_zero_time = int(time.mktime(date_zero.timetuple())) * 1000
return date_zero_time
# 今天的日期
today_date = datetime.datetime.now().date()
# 今天的零点
today_zero_time = get_day_zero_time(today_date)
print today_zero_time