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

后端 未结 7 959
闹比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:03

    If changing the timezone on your running production servers or updating a key configuration setting and restarting mysql seems unrealistic and/or overkill, try this:

    CONVERT_TZ(NOW(), 'US/Pacific', 'UTC')
    

    Where US/Pacific is the timezone your NOW() call is returning the time in.

提交回复
热议问题