24 lines
716 B
Python
24 lines
716 B
Python
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) |