Skip to content

Instantly share code, notes, and snippets.

@nsfyn55
Last active August 29, 2015 14:20
Show Gist options
  • Save nsfyn55/c1ca64e580f60a3f78a3 to your computer and use it in GitHub Desktop.
Save nsfyn55/c1ca64e580f60a3f78a3 to your computer and use it in GitHub Desktop.
Convert Timezone Aware Date to Timezone unaware UTC Equivalent
from dateutil.parser import parse
from pytz import utc
datestr = 'Fri, 24 Apr 2015 14:49:32 -0400'
dt = parse(datestr)
utc_dt = dt.astimezone(utc)
final = utc_dt.replace(tzinfo=None)
@nsfyn55
Copy link
Author

nsfyn55 commented May 1, 2015

from dateutil.parser import parse
from pytz import utc

final = parse('Fri, 24 Apr 2015 14:49:32 -0400').astimezone(utc).replace(tzinfo=None)

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