1. Use "ini_set('date.timezone','PRC')" to set the time zone.
<?php header("Content-type:text/html;charset=utf-8"); ini_set('date.timezone', 'GMT'); echo 'The current Greenwich time is:'.date('Ymd H:i:s',time()).' '; ini_set('date.timezone', 'PRC'); echo 'The current domestic time is:'.date('Ymd H:i:s',time()); ?>
2. Use "date_default_timezone_set('PRC')" to set the time zone.
<?php header("Content-type:text/html;charset=utf-8"); date_default_timezone_set('Europe/Lisbon'); echo 'The current time in Portugal is:'.date('Ymd H:i:s',time()).' '; date_default_timezone_set('PRC'); echo 'The current domestic time is:'.date('Ymd H:i:s',time()); ?>
3. In the configuration file, set "date.timezone=PRC".
[Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone ;date.timezone =
The above is the solution to the difference between the PHP display time and the actual time. I hope it will be helpful to everyone. More PHP learning guide: source code network