How do I make MySQL's NOW() and CURDATE() functions use UTC?

Chad Johnson picture Chad Johnson · Jun 3, 2009 · Viewed 54.2k times · Source

I want to make it so calls to NOW() and CURDATE() in MySQL queries return the date in UTC. How do I make this happen without going through and changing all queries that use these functions?

Answer

Chad Johnson picture Chad Johnson · Jun 3, 2009

Finally found what I was looking for...

In my.cnf,

[mysqld_safe]
timezone = UTC

I was putting this option under [mysqld], and mysql was failing to start.

Calling "SET time_zone='+0:00';" on every page load would also work, but I don't like the idea of calling that query on every single page load.