[英]subtract a few hours from a date in php
我正在尝试使用以下命令回显文件的时间戳:
Last updated: <?= date("m/d/Y H:i:s",filemtime("file1.html")) ?>
但这要比服务器提前6个小时。
我尝试使用DateTime :: sub或date_sub或sub,但是这些都没有被识别。 我需要给日期班打电话吗?
filemtime
返回一个时间戳,只需减去所需的秒数即可。
date("m/d/Y H:i:s",filemtime("file1.html")-6*3600)
或指定时区
$time = new Datetime(new Datetimezone('America/Chicago'));
$time->setTimestamp(filetime("file1.html"));
echo $time->format('m/d/Y H:i:s');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.