Last active
June 30, 2023 19:57
-
-
Save humanium/5bf951dd2e51e26bdd90 to your computer and use it in GitHub Desktop.
Date convertation utilities
This file contains 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
import datetime | |
import time | |
def timestamp_from_date(year, month, day, hour, minutes, seconds): | |
t = datetime.datetime(year, month, day, hour, minutes, seconds).timetuple() | |
return time.mktime(t) | |
def date_from_utc_timestamp(timestamp): | |
# about date string formatting: http://strftime.org/ | |
return datetime.datetime.utcfromtimestamp(timestamp).strftime('%b %d, %Y %I:%M %p') # 'Apr 18, 2015 06:04 AM' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment