Home > Database > Mysql Tutorial > Why is MySQL's CONVERT_TZ Function Returning NULL and How Can I Fix It?

Why is MySQL's CONVERT_TZ Function Returning NULL and How Can I Fix It?

Patricia Arquette
Release: 2024-12-03 15:36:11
Original
198 people have browsed it

Why is MySQL's CONVERT_TZ Function Returning NULL and How Can I Fix It?

MySQL CONVERT_TZ Function Returning Null

Problem:

When executing the following query:

SELECT CONVERT_TZ('2004-01-01 12:00:00','UTC','Asia/Jakarta') AS time
Copy after login

in MySQL Workbench on Ubuntu 12.04, NULL is returned.

Solution:

This issue occurs when the time zone table has not been loaded into MySQL. To resolve it, execute the following command:

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
Copy after login

where "mysql" is the name of the built-in database used for MySQL configuration data. This command loads the time zone information into the MySQL database, allowing the CONVERT_TZ function to work properly.

The above is the detailed content of Why is MySQL's CONVERT_TZ Function Returning NULL and How Can I Fix It?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template