How to set time zone in PHP

When we are coding a web system, we have to solve problem “time zone”, today we introduce three way to set time zone in php, look at source code below:

1.edit php.ini

you can use

<php phpinfo();?>

to find path of php.ini and edit it like this:

date.timezone = PRC

2.we set time zone in php script

you can do this like:

<?php

date_default_timezone_set('Asia/Shanghai');

date_default_timezone_set('Asia/Chongqing');

date_default_timezone_set('PRC');

?>

or

ini_set('date.timezone','Etc/GMT-8');

ini_set('date.timezone','PRC');

ini_set('date.timezone','Asia/Shanghai');

ini_set('date.timezont','Asia/Chongqing');

,