Skip to content

Instantly share code, notes, and snippets.

@davidmezzetti
Created February 6, 2020 16:25
Show Gist options
  • Save davidmezzetti/32eca7f8750f40e482e10a4b3e37e997 to your computer and use it in GitHub Desktop.
Save davidmezzetti/32eca7f8750f40e482e10a4b3e37e997 to your computer and use it in GitHub Desktop.
>>> import pytz
>>> from pytz import timezone
>>> utc = pytz.utc
>>> eastern = timezone('US/Eastern')
>>> date = datetime.utcnow().astimezone(utc)
>>> date
datetime.datetime(2020, 2, 6, 21, 22, 49, 384018, tzinfo=<UTC>)
>>> date.astimezone(eastern)
datetime.datetime(2020, 2, 6, 16, 22, 49, 384018, tzinfo=<DstTzInfo 'US/Eastern' EST-1 day, 19:00:00 STD>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment