# 获取今天开始的时间戳
def get_current_day_begin_timestamp():
time_string = datetime.fromtimestamp(
time.time()).strftime('%Y-%m-%d 00:00')
timestamp = time.mktime(datetime.strptime(
time_string, "%Y-%m-%d 00:00").timetuple())
return float(timestamp) - 8 * 60 * 60
# 计算这周开始的时间戳
def get_current_week_begin_timestamp():
date1 = datetime.now()
this_week_start_dt = str(date1-timedelta(days=date1.weekday())).split()[0]
timestamp = time.mktime(datetime.strptime(this_week_start_dt, "%Y-%m-%d").timetuple())
return timestamp - 8 * 60 * 60
网友评论