Home >Backend Development >PHP Problem >How to set time zone in php 5.3

How to set time zone in php 5.3

王林
王林Original
2021-06-24 14:42:081915browse

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.

How to set time zone in php 5.3

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn