问题
We can use any simple code to display the system time only but I need some code to find the server(PHP) time zone and how to change the server time zone?
回答1:
date_default_timezone_set('America/Los_Angeles');
Change the value of America/Los_Angeles');
回答2:
Add this to the top of a PHP file, or to the top of an included file (if you can't get at the PHP.ini)...
date_default_timezone_set('America/Los_Angeles');
From php.net
回答3:
Here is function: http://php.net/manual/en/function.date-default-timezone-set.php
Here are timezones: http://www.php.net/manual/en/timezones.php
And this is how you use it:
date_default_timezone_set('Europe/Vilnius');
回答4:
For server: In the php.ini change the date.timezone variable
For script: Refer to the API: http://php.net/manual/en/function.date-default-timezone-set.php
回答5:
Use function date_default_timezone_set() in your PHP file.
来源:https://stackoverflow.com/questions/13229564/how-to-change-the-php-server-time-zone