Skip to content

Instantly share code, notes, and snippets.

@chandra-prakash-meghwal
Created October 18, 2022 08:57
Show Gist options
  • Save chandra-prakash-meghwal/d13f70258476aa7dde54c3ac7676688d to your computer and use it in GitHub Desktop.
Save chandra-prakash-meghwal/d13f70258476aa7dde54c3ac7676688d to your computer and use it in GitHub Desktop.
Get Date Time in UTC from the given timestamp
import datetime
def get_utc_datetime_from_timestamp(timestamp):
"""
datetime.datetime.utcfromtimestamp returns utc date time
whereas datetime.datetime.fromtimestamp returns local (system) date time
"""
return str(datetime.datetime.utcfromtimestamp(int(timestamp)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment