HowdoIchangeMySQLtimezone?_PHP教程
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了HowdoIchangeMySQLtimezone?_PHP教程,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1588字,纯文字阅读大概需要3分钟。
内容图文
![HowdoIchangeMySQLtimezone?_PHP教程](/upload/InfoBanner/zyjiaocheng/167/79bc393acda94c659d4745e18d6382f8.jpg)
Knowing the time offset, you can replace all your SQL statements of
SELECT NOW();
with
SELECT DATE_ADD(NOW(), INTERVAL 2 HOUR);
which will give you an EST date result. For a result in PST, you would do:
SELECT DATE_SUB(NOW(), INTERVAL 1 HOUR);
If you are working with time in seconds instead of dates, then factor in the offset in seconds. Because there are 3600 seconds in an hour, and EST is 2 hours later than MST, the following converts timestamps from MST to EST:
SELECT unix_timestamp() + (3600 * 2);
SELECT FROM_UNIXTIME(UNIX_TIMESTAMP() + (3600 * 2));
See the MySQL Manual's Date and Time Functions for more information.
Depending on your application, you may also need to do one of the following (but not both):
1. Find every place in your code where a date or time is displayed to the browser and have a user defined function change it to add or subtract the appropriate number of hours before displaying it.
2. Find every place in your code where dates or times are input into your system and have a user defined function add or subtract the appropriate number of hours before storing it.
http://www.bkjia.com/PHPjc/318622.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/318622.htmlTechArticleHowever,therearewaysforyoutogetresultsthatareinyourpreferredtimezone.FirstdeterminehowmanyhoursyourdesiredtimezoneisofffromMST.Forexample,ESTis+2hours.PSTis-1hour. Knowingthetimeof...
内容总结
以上是互联网集市为您收集整理的HowdoIchangeMySQLtimezone?_PHP教程全部内容,希望文章能够帮你解决HowdoIchangeMySQLtimezone?_PHP教程所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。