from datetime import datetime as dt
import pytz
import tzlocal
def get_my_timezone():
return pytz.timezone('Asia/Shanghai')
def get_local_timezone():
return tzlocal.get_localzone()
def get_aware_datetime(datetime, timezone):
return timezone.localize(datetime)
def get_timestamp():
return int(dt.now().timestamp())
def get_datetime_from_timestamp(timestamp):
return dt.fromtimestamp(int(timestamp))
Python - datetime with timezone
猜你喜欢
转载自www.cnblogs.com/zhangzhihui/p/12817456.html
今日推荐
周排行