When attempting to use the CONVERT_TZ() function to convert UTC timestamps to local time zones, you may encounter unexpected results. While the general syntax of the query you provided should work, it's important to verify a few aspects to ensure successful execution.
If the CONVERT_TZ() function is not working as expected, check if your database has initialized the timezone tables. Empty timezone tables can cause the function to behave erratically. To resolve this, run the mysql_tzinfo_to_sql program to load the necessary data.
The CONVERT_TZ() function is compatible with timestamp and date column types. Ensure that the displaytime column in your table is one of these types.
Double-check the timezone parameters you specified in the function. Make sure the 'GMT' and 'MET' values in your query are correct for the intended conversion.
A working example of the query with the correct parameters could look like this:
SELECT CONVERT_TZ(a_ad_display.displaytime, '+00:00', '+04:00');
For further guidance and documentation on time zone support in MySQL, refer to the following resources:
以上是为什么我的 CONVERT_TZ() 函数无法准确转换 UTC 时间戳?的详细内容。更多信息请关注PHP中文网其他相关文章!