Use the library time
import time
print(time.time()) #1643195041.575819 Returns the current timestamp float
# time.time() The time stamp indicates that the 1970 year 1 month 1 Japan 00:00:00 Start offset in seconds .
print(time.localtime()) # Local time zone struct_time( Beijing time. )
# time.struct_time(tm_year=2022, tm_mon=1, tm_mday=26, tm_hour=23, tm_min=56, tm_sec=5, tm_wday=2, tm_yday=26, tm_isdst=0) And time,time() The timestamp corresponds to
print(time.gmtime()) # UTC Time zone struct_time( GMT )
# time.struct_time(tm_year=2022, tm_mon=1, tm_mday=26, tm_hour=15, tm_min=56, tm_sec=5, tm_wday=2, tm_yday=26, tm_isdst=0) from 1970.1.1 08:00:00 Count up
print(time.localtime(time.time())) # Return a date structure time.struct_time(tm_year=2022, tm_mon=1, tm_mday=26, tm_hour=19, tm_min=5, tm_sec=23, tm_wday=2, tm_yday=26, tm_isdst=0)
print(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime()))
# 2022-01-27
print(time.strptime('2001-07-18','%Y-%m-%d'))
# time.struct_time(tm_year=2001, tm_mon=7, tm_mday=18, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=2, tm_yday=199, tm_isdst=-1)