Created
June 23, 2019 23:09
-
-
Save StickmanNinja/ecd7a8ee8816a838b202fbc44e1f4979 to your computer and use it in GitHub Desktop.
This python short function returns the epoch timestamp for a given date.
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
def convertGivenTimeToEpoch(year, month, day, hour, minute, ampm): | |
from datetime import * | |
m2 = str(hour) + ":" + str(minute) + " " + str(ampm.lower()) | |
m2 = datetime.strptime(m2, '%I:%M %p') | |
m2 = str(m2) | |
m2 = m2.split(" ")[1] | |
m2.split(":") | |
time2 = datetime.datetime(1970,1,1,0,0,0) | |
time1 = datetime.datetime(year, month, day, m2[0], m2[1], m2[2]) | |
x = (time1 - time2).total_seconds() | |
return x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment