您的位置:首页 > 编程语言 > PHP开发

PHP 处理2038后的日期

2016-07-11 11:04 411 查看
将时间戳转为年月日

$d = new DateTime("@21474836490");
$d->setTimezone(new DateTimeZone("PRC"));
echo $d->format("Y-m-d H:i:s");


将年月日转为时间戳

$d = new DateTime('2650-07-06 16:21:30');
echo '<br/>'.$d->format('U');


运行时 可能会报

warning: It is not safe to rely on the system’s timezone settings

(最好的方法)在php.ini里加上找到date.timezone项,设置date.timezone = “Asia/Shanghai”,重启环境就ok了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  php