Home  >  Article  >  Backend Development  >  Two ways to set time zone in php

Two ways to set time zone in php

WBOY
WBOYOriginal
2016-07-25 08:57:27911browse
  1. date.timezone = PRC
Copy code

Set time zone in code

  1. date_default_timezone_set('Asia/Shanghai');//'Asia/Shanghai' Asia/Shanghai
  2. date_default_timezone_set('Asia/Chongqing');//where Asia/Chongqing' is "Asia/Chongqing"
  3. date_default_timezone_set ('PRC');//where PRC is "People's Republic of China"
  4. ini_set('date.timezone','Etc/GMT-8');
  5. ini_set('date.timezone','PRC');
  6. ini_set ('date.timezone','Asia/Shanghai');
  7. ini_set('date.timezone','Asia/Chongqing');
Copy code

Any of the above seven methods can satisfy us need.

During system initialization, add:

  1. ini_set('date.timezone','Asia/Shanghai'); or date_default_timezone_set("PRC");
Copy the code

to solve the problem of 8 hours difference in time zones.



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