import datetime import time import pytz as pytz if __name__ == '__main__': tz = pytz.timezone('Asia/Shanghai') # 东八区 t = datetime.datetime.fromtimestamp(int(time.time()), tz).strftime('%Y-%m-%d %H:%M:%S %Z%z') print(t) # 2021-10-14 21:28:15 CST+0800
import datetime import time import pytz as pytz if __name__ == '__main__': tz = pytz.timezone('Asia/Shanghai') # 东八区 t = datetime.datetime.fromtimestamp(int(time.time()), tz).strftime('%Y-%m-%d %H:%M:%S %Z%z') print(t) # 2021-10-14 21:28:15 CST+0800