我正在尝试将纪元转换为人类友好的日期时间。我还有1小时就下班了为什么?
$aptTime = 1694194200;
if(!empty($aptTime)) {
$aptDisplay = new dateTime("@$aptTime");
$aptDisplay->setTimezone(new DateTimeZone('EST'));
$aptStr = date_format($aptDisplay, "l F jS \a\\t g:i A");
$html = '<p class="feature-box-desc text-dark" id="apt"><strong>' . $aptStr . '</strong></p>';
}
预计产出:9 月 8 日星期五下午 1:30
生成的输出:9 月 8 日星期五中午 12:30
如果您不想确认夏令时
这将为您提供所需的输出
$aptDisplay->setTimezone(new DateTimeZone('Etc/GMT+4'));
或者如果您承认 DST,那么您的解决方案就是准确的。