为什么我的 CONVERT_TZ() 函数无法准确转换 UTC 时间戳?

Susan Sarandon
发布: 2024-11-14 11:15:02
原创
697 人浏览过

Why is my CONVERT_TZ() function not accurately converting my UTC timestamps?

Potential Issue with Using CONVERT_TZ() Function

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.

Error Handling

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.

Column Type

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.

Timezone Parameters

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.

Sample Query

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');
登录后复制

Additional Resources

For further guidance and documentation on time zone support in MySQL, refer to the following resources:

  • [Date and Time Functions - CONVERT_TZ()](http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_convert-tz)
  • [MySQL Time Zone Support](http://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html)
  • [mysql_tzinfo_to_sql](http://dev.mysql.com/doc/refman/5.5/en/mysql-tzinfo-to-sql.html)

以上是为什么我的 CONVERT_TZ() 函数无法准确转换 UTC 时间戳?的详细内容。更多信息请关注PHP中文网其他相关文章!

来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板