Home >Backend Development >PHP Tutorial >What should I do if the system time obtained by PHP date is incorrect? How to display uptodate datealive in php isodate

What should I do if the system time obtained by PHP date is incorrect? How to display uptodate datealive in php isodate

WBOY
WBOYOriginal
2016-07-29 08:48:451363browse

Using PHP to get the system time, I found that the time was wrong because the default time zone of PHP is UTC, and its time zone should be set to Beijing time.

Method 1: Modify the php.ini file
Open the php.ini file: left-click the WampServer icon in the lower right corner - PHP - php.ini,
Find date.timezone, find date.timezone="UTC",
Change it to date.timezone = "PRC". If there is a semicolon on the left side of date.timezone, remove the semicolon.

<code><span><<span>span</span><span>class</span>=<span>"cur_time"</span>></span><span><span><?php</span><span>echo</span><span>"当前时间:"</span> . date(<span>"Y-m-d H:i:s"</span>) <span>?></span></span><span></<span>span</span>></span></code>

Method 2: Use date_default_timezone_set(”) method;

<code><span><?php</span>
date_default_timezone_set(<span>'PRC'</span>); 
<span>echo</span> date(<span>"Y-m-d H:i:s"</span>);
<span>?></span></code>
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces what to do if the system time obtained by PHP date is wrong? It includes the content of PHP date. I hope it will be helpful to friends who are interested in PHP tutorials.

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