CDbExpression('NOW()') and timezones

Does CDbExpression(‘NOW()’) handle timezones? I’m currently setting my timezone in my application to


Then I’m storing some dates in the database with CDbExpression(‘NOW()’) however when I look in the database the time set is to the server time which is in the pacific time zone. How do I get the timestamp to be in the proper eastern timezone?

Thanks in advance!

Since NOW() is evaluated in the Database, this is an issue of DB configuration. You should check the MySQL docs, on how to configure the server timezone there.

What I do, since I don’t have any control over my mysql server, is setting the timezone to UTC and use time() instead of NOW() when saving time/dates. ;)


and for timestamps:

date("Y-m-d\TH:i:s\Z", time());

Thank you both. I wasn’t sure if it was appropriate to use time() instead, but it makes sense if CDbExpression(‘NOW()’) is a MySQL setting and I need to have control over timezones being displayed on the front end.