from pytz import timezone
def datetime_as_timezone(date_time, time_zone): tz = timezone(time_zone) utc = timezone(‘UTC‘) return date_time.replace(tzinfo=utc).astimezone(tz) def datetime_to_str(date_time): date_time_tzone = datetime_as_timezone(date_time, ‘Asia/Shanghai‘) return ‘{0:%Y-%m-%d %H:%M}‘.format(date_time_tzone)
时间: 2024-10-09 19:35:59