What timezone does MySQL's NOW() follow

前端 未结 3 837
你的背包
你的背包 2020-12-10 12:34

Does MySQL\'s NOW() follow the system\'s timezone or some standard like GMT or UTC?

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-10 13:18

    Per the docs, the rules are complicated, but mostly boil down to "current session's timezone" (which defaults to system timezone):

    The current session time zone setting affects display and storage of time values that are zone-sensitive. This includes the values displayed by functions such as NOW() or CURTIME(), and values stored in and retrieved from TIMESTAMP columns. Values for TIMESTAMP columns are converted from the current time zone to UTC for storage, and from UTC to the current time zone for retrieval.

    Of course you can use UTC_TIMESTAMP() if you need UTC specifically.

提交回复
热议问题