Home >Backend Development >PHP Tutorial >PHP date 年份太大 结果就错误 请问怎么解决?

PHP date 年份太大 结果就错误 请问怎么解决?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 13:38:001086browse

echo date('Y-m-d H:i:s',3356676867);
错误结果:1940-04-08 11:46:11
正确为2076/5/14 18:14:27

请问怎么才能输出这样的答案。


回复讨论(解决方案)

?考: http://blog.csdn.net/fdipzone/article/details/39457681

$dt = new DateTime('@3356676867');  echo $dt->format('Y-m-d H:i:s'); // 2076-05-14 10:14:27

?了,上??有?置??,所以不?。

$dt = new DateTime('@3356676867');  $tz = timezone_open('Asia/SHANGHAI');  $dt->setTimezone($tz);  echo $dt->format('Y-m-d H:i:s'); // 2076-05-14 18:14:27



xu大说的没错,碰到问题多看看手册
如果有需求,你可以自行编写一个递归函数,当时间大于date()函数上限时,减去4年的秒数,进入有效范围计算出结果后,再把减过的多少个4年加回去

非常感谢楼上两位, 我是初学,还有许多不懂

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