Does MySQL's NOW() follow the system's timezone or some standard like GMT or UTC?
It's in the current time zone. From the 5.1 docs: Returns the current 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.
By default, the time zone for a MySQL DB instance is Universal Time Coordinated (UTC). You can set the time zone for your DB instance to the local time zone for your application instead.
You can check all of the supported timezone names by using the following query: select * from pg_timezone_names; Let's exit our psql session, and reenter into it again.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With