


The time of php time() and date() is different from that of the local computer_PHP tutorial
Jul 13, 2016 am 10:43 AMMy classmates often ask me why the time of php time() and date() is different from that of the local computer. How many hours are there? If you calculate it carefully, there is a difference of 8 hours. This is a problem with the time zone setting of php date_default_timezone_set , we just need to set it up simply.
If the date time is inconsistent, you can use date_default_timezone_set to set the time zone:
The code is as follows
|
Copy code
|
||||
";
//Calculate the current time
echo date('Y-m-d H:i:s',time()-600); //Subtract 10 hours
echo " "; //Timestamp to time echo date('Y-m-d H:i:s',1364277600); //Convert time to timestamp (accurate to seconds only) echo strtotime("2013-03-26 14:00"); echo " ";
|
In addition to the above method, we can also set a time zone in php.ini, so that in the future there will be no need to add date_default_timezone_set('Asia/Chongqing'); in the program

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

deepseek why can't you log in deepseek login portal

Pi Node Teaching: What is a Pi Node? How to install and set up Pi Node?

Why can't the Bybit exchange link be directly downloaded and installed?
