MySQL CONVERT_TZ () returns null if one of the arguments is "+14: 00",

I am trying to convert UTC time to users local time, it works fine until I try to convert time to +14: 00 timezone, the result is always zero, who has an idea? Here is my code:

select CONVERT_TZ(now(), '+00:00', '+14:00')
+7
source share
2 answers
+4
source

You can fix this by using the time zone name instead of the offset. UTC +14:00corresponds to the time zone Pacific/Kiritimati. So if you change the request to:

SELECT CONVERT_TZ(NOW(), '+00:00', 'Pacific/Kiritimati')

or

SELECT CONVERT_TZ(NOW(), 'UTC', 'Pacific/Kiritimati')

, NULL.

. MySQL . NULL, , , MySQL.

, :

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

, : convert_tz

MySQL 5.6.36.

+1

Source: https://habr.com/ru/post/1609825/


All Articles