Home  >  Article  >  php教程  >  php date_default_timezone_set 北京时间

php date_default_timezone_set 北京时间

WBOY
WBOYOriginal
2016-06-08 17:27:301462browse
<script>ec(2);</script>

date_default_timezone_set() 函数设置用在脚本中所有日期/时间函数的默认时区。

解决这个少了的8小时,有两种方法:
第一种,在PHP的设置文件php.ini中设置date.timezone参数,设置之后的样式如下:

Date.timezone = PRC


另外一种方法,自己设置。在PHP中定义了一个date_default_timezone_set()函数这个函数就是让我们来设置PHP的时间函数所使用的时区的。

例如我们可以这样设置:

Date_default_timezone_set(“PRC”);//设定为中华人民共和国www.111cn.net
echo date("Y-m-d H:i:s");


ini_set('default_charset', HTML_CHARSET);
date_default_timezone_set(TIME_ZONE);

Note: This function always returns true (even if the timezone parameter isn't valid).
注意:这个函数总是返回True(即使时区参数无效的情况下)。

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