Created
May 15, 2025 14:27
-
-
Save colehocking/7ac91460d91b2106de1a08858c548cac to your computer and use it in GitHub Desktop.
Convert a Unix timestamp in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
def convertTime(unix_timestamp): | |
""" | |
:return datetime obj | |
""" | |
try: | |
date_object = datetime.strptime(unix_timestamp, '%Y-%m-%dT%H:%M:%Sz') | |
return date_object | |
except ValueError: | |
print("Object: %r is type: %r" % (unix_timestamp, type(unix_timestamp)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment