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

后端 未结 7 971
闹比i
闹比i 2020-12-08 13:17

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

7条回答
  •  生来不讨喜
    2020-12-08 14:04

    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.

提交回复
热议问题