Skip to content

Instantly share code, notes, and snippets.

@utylee
Created July 19, 2020 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save utylee/afb173a5ea39eb5264ebf75c5fb95105 to your computer and use it in GitHub Desktop.
Save utylee/afb173a5ea39eb5264ebf75c5fb95105 to your computer and use it in GitHub Desktop.
python datetime format timezone gmt utc kst correction
import datetime
#Sat, 18 Jul 2020 16:05:42 GMT
#fmt = '%a, %d %b %Y %H:%M:%S GMT'
fmt = '%d %b %Y %H:%M:%S'
dump_ts_str = datetime.datetime.strptime(server_time, fmt)
#dump_ts_str = time.strptime(server_time, fmt)
KST = datetime.timezone(datetime.timedelta(hours=9))
dump1_ts_str = dump_ts_str.replace(tzinfo=datetime.timezone.utc).astimezone(tz=KST)
#korea_1_1 = datetime.datetime(2019, 1, 1, 0, 0, 0, tzinfo=KST)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment