Skip to content

Instantly share code, notes, and snippets.

@jerryan999
Created December 13, 2018 10:32
Show Gist options
  • Save jerryan999/e7c2587fb0f27a6e05e727067322e3a5 to your computer and use it in GitHub Desktop.
Save jerryan999/e7c2587fb0f27a6e05e727067322e3a5 to your computer and use it in GitHub Desktop.
compare normal datetime and timezone-aware datetime
from datetime import datetime, timedelta, timezone
TZ_DELTA = 0 # Define timezone, UTC '0'
tzinfo = timezone(timedelta(hours=TZ_DELTA))
# timezone-aware datetime
now = datetime.now(tz=tzinfo)
# normal datetime
now = datetime.now()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment