Python - datetime with timezone

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))


猜你喜欢

转载自www.cnblogs.com/zhangzhihui/p/12817456.html