Skip to content

Instantly share code, notes, and snippets.

@humanium
Last active June 30, 2023 19:57
Show Gist options
  • Save humanium/5bf951dd2e51e26bdd90 to your computer and use it in GitHub Desktop.
Save humanium/5bf951dd2e51e26bdd90 to your computer and use it in GitHub Desktop.
Date convertation utilities
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