Home >Backend Development >PHP Tutorial >函数date()的用法?

函数date()的用法?

WBOY
WBOYOriginal
2016-06-23 13:42:171397browse

当前服务器时间15年1月4号17点29,为什么echo(date('ymdHis'));显示150104102900,这个应该是10点29的意思吧,怎么差了7个小时?是不是有哪里有时区之类的设置?


回复讨论(解决方案)

你应该是php.ini 没有设置date.timezone  
你可以在代码里直接这样设置 就可以了
date_default_timezone_set('PRC');

php.ini中有个date.timezone

ini_set('date.timezone','Asia/Shanghai');echo(date('ymdHis')).'<br>';// 或者$t = timezone_open('Asia/Shanghai');$dt = new Datetime();$dt->setTimezone($t);echo $dt->format('ymdHis');

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