How to change default time zone in php

大城市里の小女人 提交于 2019-12-25 04:06:57

问题


i received a website built in php and mysql, but the coder left the default time zone in UTC format, how do i change that to EDT so all of the controls within the site now use EDT time NOT UTC. I've looked throughout the code and the coder calls strttotime in some places but i dont see timezone anywhere, the times that show up everywhere come from database columns containing UNIX timestamp with strttotime.


回答1:


For PHP:

date_default_timezone_set('America/New_York');

http://php.net/manual/en/function.date-default-timezone-set.php

This is also configurable in your server's php.ini file.

For MySQL, in my.cnf:

default_time_zone='America/New_York'

or for a single session, a query of:

SET time_zone = 'America/New_York';


来源:https://stackoverflow.com/questions/27348112/how-to-change-default-time-zone-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!