Comparing times
Go to solution
Solved by mathijs727,
6 hours ago, espurritado said:python has datetime. wit it you can create an object representing a time, a date or a date and time.
you can make it so it parses an input string in whichever format you want to give it to it
15 hours ago, HeaterUp said:So what I am looking to do is compare if 11:15 am is before the time of 10:30 am and different times this same way. I know I could take the first two numbers and compare the hour then compare the next two numbers as the minutes and evaluate the am or pm but is there an easier way to accomplish this? Maybe a python library or anything like that?
In Python (using dateutil library)
from dateutil import parser if __name__ == "__main__": t1 = parser.parse("10:40") t2 = parser.parse("11:50") print(t2 - t1)
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now