In simple terms, the timestamp is how many seconds the current time is from 1970-01-01T00:00:00Z.
For example, the current time is 10:32:50 on July 6, 2022, so the timestamp corresponding to this time point is 1657074770
1. Timestamp acquisition
import time
now=time.time()#获取当前时间时间戳
2. Convert millisecond-level timestamps to dates
When the timestamp is 1678723200000
import time
now = int(1678723200000/1000)
timeArray = time.localtime(now)
otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
print(otherStyleTime)
3. Second-level timestamp conversion
import time
now = time.time()
timeArray = time.localtime(now)
otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
print(now)
print(otherStyleTime)