2020-09-25T18:00:00Z
→ 2020-09-26 03:00:00
I don't think I need such a long program by any means ...
# coding: utf-8
from datetime import datetime, timezone, timedelta
import dateutil.parser
def time_jst(date_str: str):
date_str.replace('Z', '+00:00')
t = dateutil.parser.parse(date_str)
JST = timezone(timedelta(hours=+9))
t_jst = t.astimezone(JST)
ret = t_jst.strftime("%Y-%m-%d %H:%M:%S")
return ret
s = '2020-09-25T18:00:00Z'
print (time_jst(s))
Recommended Posts