Skip to content

Instantly share code, notes, and snippets.

@gitzhou
Created June 8, 2020 19:02
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 gitzhou/cf45e91088ccf48ecffa80e2e67ea9f3 to your computer and use it in GitHub Desktop.
Save gitzhou/cf45e91088ccf48ecffa80e2e67ea9f3 to your computer and use it in GitHub Desktop.
Get local time of specific timezone from UTC
from pytz import timezone
from datetime import datetime
now = timezone('Asia/Shanghai').fromutc(datetime.utcnow())
print(now.strftime('%Y-%m-%d %H:%M:%S'))
@gitzhou
Copy link
Author

gitzhou commented Jun 8, 2020

2020-06-09 03:03:04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment