Skip to content

Instantly share code, notes, and snippets.

@jsnns
Created December 31, 2018 16:53
Show Gist options
  • Save jsnns/92cd570f9a9a0b2c3fa6071119522210 to your computer and use it in GitHub Desktop.
Save jsnns/92cd570f9a9a0b2c3fa6071119522210 to your computer and use it in GitHub Desktop.
import datetime
import pytz
import dateutil.parser
def to_utc(str, *, zulu_marker=False):
# string formats
from_format = '%m/%d/%Y %I:%M:%S %p'
to_format = '%m/%d/%Y %H:%M:%S'
d = datetime.datetime.strptime(datestring, from_format)
formated_datetime = d.strftime(to_format)
if zulu_marker:
formated_datetime += "Z"
return formated_datetime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment