Possible Duplicate:
How to compare datetime in Django?
I need to compare 2 dates
object.submit_date.ctime() > user.last_login.ctime()
but always get false.
no matter whether last_login it is after the last submit_date
are comparing wrong, you have to use date() or isoformat() instead of ctime()
Like this:
object.submit_date.isoformat() > user.last_login.isoformat()
this includes the time
or
object.submit_date.date() > user.last_login.date()
If its a datetime
object. you can simply compare the datetime ojects rather than using ctime.
>>> a =datetime.now()
>>> b = datetime.now()
>>> a>b
False
>>> b>a
True
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With