import time # 輸入毫秒級的時間,轉出正常格式的時間 # def timeStamp(timeNum): timeStamp = float(1603346322020/1000) timeArray = time.localtime(timeStamp) otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray) print(otherStyleTime) # timeStamp('1603346322020')
獲取當前時間的13位時間戳
datetime_now = datetime.now() # 10位,時間點相當於從UNIX TIME的紀元時間開始的當年時間編號 date_stamp = str(int(time.mktime(datetime_now.timetuple()))) # 3位,微秒 data_microsecond = str("%06d" % datetime_now.microsecond)[0:3] date_stamp = date_stamp + data_microsecond stamp = int(date_stamp)
