Home >Backend Development >PHP Problem >How to set time zone in php 5.3
php 5.3 can set the time zone by modifying the php.ini file, modifying the .htaccess file, or modifying the php code. Let's take modifying the php.ini file as an example. We only need to find [date.timezone = Asia/Shanghai] and remove the comment.
The operating environment of this article: windows10 system, php 5.3, thinkpad t480 computer.
Versions before PHP5.2.4 do not need to set the time zone. We usually have the following three methods to modify the time zone:
Modify the PHP.ini file
Find the date.timezone line and remove the previous one Semicolon, change it to:
date.timezone = Asia/Shanghai
Modify the .htaccess file
There are two ways to modify the .htaccess file. The following two statements only need to be Just one statement
php_value date.timezone Asia/Shanghai SetEnv TZ Asia/Shanghai
Modify the PHP code
Also only one of the following two statements is enough
date_default_timezone_set('Asia/Shanghai'); ini_set('date.timezone','Asia/Shanghai');
Related video tutorial sharing: php video tutorial
The above is the detailed content of How to set time zone in php 5.3. For more information, please follow other related articles on the PHP Chinese website!