24 lines
716 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from datetime import datetime
import time
def get_current_date_and_milliseconds():
# 获取当前日期和时间
now = datetime.now()
# 格式化日期为 YYYYMMDD 格式
formatted_date = now.strftime("%Y%m%d")
# 获取当前时间的时间戳,包含毫秒
timestamp = time.time()
# 获取13位长度的时间戳毫秒级
milliseconds_timestamp = int(timestamp * 1000)
return formatted_date, milliseconds_timestamp
# # 获取当前日期和13位长度的时间戳
# current_date, current_milliseconds = get_current_date_and_milliseconds()
# print("Current date in YYYYMMDD format:", current_date)
# print("13-digit timestamp (milliseconds):", current_milliseconds)