【问题标题】:Need to remove Minutes from Date需要从日期中删除分钟
【发布时间】:2020-11-29 22:30:44
【问题描述】:
$date = new DateTime("now", new DateTimeZone('Europe/Berlin') );
$dateUpdate = $date->format("d.m.Y H:i:s");

嘿,我需要从$dateUpdate 中减去 4 分钟。 这怎么可能?

谢谢

【问题讨论】:

标签: php html date format subtraction


【解决方案1】:

你可以这样做:

$date = new DateTime("now", new DateTimeZone('Europe/Berlin'));
$interval = new DateInterval("PT4M");
$date->sub($interval);
echo $date->format('Y-m-d\TH:i:s.u');

DateTime Documentation

DateInterval Documentation

【讨论】:

    猜你喜欢
    • 2017-06-10
    • 2014-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-05
    • 1970-01-01
    相关资源
    最近更新 更多