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

后端 未结 7 962
闹比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:02

    UTC_TIMESTAMP()
    

    Returns the current UTC date and time as a value in 'YYYY-MM-DD hh:mm:ss' or YYYYMMDDhhmmss.uuuuuu format, depending on whether the function is used in a string or numeric context.

    UTC_DATE()
    

    Returns the current UTC date as a value in 'YYYY-MM-DD' or YYYYMMDD format, depending on whether the function is used in a string or numeric context.

    UTC_TIME()
    

    Returns the current UTC time as a value in 'hh:mm:ss' or hhmmss.uuuuuu format, depending on whether the function is used in a string or numeric context.

    MySQL reference: https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_utc-timestamp

提交回复
热议问题