# 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
本文介绍了一种Python方法,用于获取指定日期的当天凌晨时间的时间戳,通过使用datetime模块,该方法能够精确到毫秒。
457

被折叠的 条评论
为什么被折叠?



