Skip to content

Instantly share code, notes, and snippets.

@JulianNorton
Last active June 26, 2017 23:53
Show Gist options
  • Save JulianNorton/0fdfb8436a9ef94f185e19304d396fd1 to your computer and use it in GitHub Desktop.
Save JulianNorton/0fdfb8436a9ef94f185e19304d396fd1 to your computer and use it in GitHub Desktop.
Convert UNIX timestamp to human readable date
from datetime import datetime as dt
# timestamp microseconds
timestamp = '1490871689000'
# String to remove miliseconds or it'll break
converted_timestamp = int(timestamp[:-3])
# I want a timestamp that's human readable!
converted_timestamp = dt.fromtimestamp(converted_timestamp)
# 2017-03-30 07:01:29
# THIS CHANGES DEPENDING ON YOUR TIME ZONE!
print(converted_timestamp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment