Compare timestamps?

I have a table with a field of the type DATETIME in the database.

Now i want to compare if this field is greater or less than the actual time so i can indicate if the time has passed or not when displaying this record.

What would be the best solution for this. Yes one could use CDateParser, but since the DATETIME field also contains the time I will have to do some preprocessing before I pass it on. This preprocessing might be location dependent, I don't know.

Is it a good idea to add an extra calculated field in the Model for the table. If so, how do I do that an can even be done?

Or does anybody have any other good ideas?

Any help appreciated.

This might be better done with mysql, eg you could pull all rows created before today.  Something like this probably, you may have to google it: <= NOW()

I think there are a whole bunch of mysql functions for this stuff

Yes i suppose it would be better done with SQL. But can i create a calculated field in the CActiveRecord like 'date<NOW() as isOld' and use isOld when i display a record or even use it to tell if the record can be edited.

Yeah you'd need one of the magic methods, eg

function getIsOld() {…}

function setIsOld($val) {…}

As for the actual logic to compare a datetime string to another date via php, idk on the top of my head, but I fell like google would have a lot of knowledge on that.  CakePHP had a helper for this I think, so you could look at their code too.