Home >Backend Development >PHP Problem >How to set server time in php
How to set the server time in php: first find and open the "php.ini" configuration file; then modify the value of "date.timezone" to successfully set the time zone of the php server.
Recommended: "PHP Video Tutorial"
Apache PHP server time time zone modification and time comparison
To do a project, I need to use PHP to compare the current time. I found that there is a big difference between the current time displayed by PHP and the actual time, so I checked the information and modified it——
In PHP. Modify the date.timezone value in the ini configuration file to successfully set the time zone of the php server
Other reference values:
(Asia/Chongqing (重庆),Asia/Shanghai (上海),Asia/Urumqi (乌鲁木齐),Asia/Macao (澳门),Asia/Hong_Kong (香港),Asia/Taipei (台北))
By the way, get the current time Example usage for comparing times:
$now_time=date("y-m-d H:i:s");//获取当前时间,具体参数格式参照第二个参考链接 if(strtotime($end_time)<strtotime($now_time))//比较时间{ //$end_time是另一个时间变量值 //这里表示$end_time比当前时间来得早 }
The above is the detailed content of How to set server time in php. For more information, please follow other related articles on the PHP Chinese website!