PHP solves server US time problem

WBOY
Release: 2016-07-29 09:15:42
Original
1175 people have browsed it
The speed of foreign servers is okay, and there is no need to register or anything. However, I found a problem in the past two days. The time of calling the output is not correct. They are all using American time. This is a problem. For example, today is April. 2nd, but the page shows April 1st, which is not good. I checked the information and found that the code is very easy to use. Share it:

$date = putenv('TZ=America/Chicago ');
mktime(0,0,0,1,1,1970) ;
echo date("Y-m-d H:i:s");

When using it, change "TZ=America/Chicago" to Your local time zone, such as "TZ=Asia/Shanghai"

The above introduces how PHP solves the problem of server US time, including aspects of the problem. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!