[Tutor] How to compare dates which has (,)

Danny Yoo dyoo at hashcollision.org
Thu Mar 10 15:50:50 EST 2016


> but I am not understanding how do i capture and compare dates in bellow
> formate (,) :
> <Mar 4, 2016 5:38:58 AM BRT>

Do you know the name or structure of the format that you're seeing here?  I
would assume BRT represents some timezone, but I am not sure.  Let me
check...

http://www.timeanddate.com/time/zones/brt

OK, so yes, that's the Brasilia time zone.

You should be able to use the date time libraries to parse the string.
https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior

The resulting values should be comparable, if I recall correctly.  Yes,
https://docs.python.org/2/library/datetime.html#datetime-objects notes that
the datetime objects support comparison.

I'm away from a keyboard at the moment, so I can't write an example right
now.

If you can convince whoever is generating those timestamps to use something
like ISO 8601 format, then that might also be nice.

Good luck!


More information about the Tutor mailing list