how do I subtract 24 hour from date time object in PHP

后端 未结 10 1399
我寻月下人不归
我寻月下人不归 2020-12-17 07:57

I have the following code:

  $now = date(\"Y-m-d H:m:s\");
  $date = date(\"Y-m-d H:m:s\", strtotime(\'-24 hours\', $now));

However, now it

10条回答
  •  借酒劲吻你
    2020-12-17 08:21

    Simplest way to sub or add time,

    format('Y-m-d H:m:s'));
    **#Add 24 hours**
    $dtAdd = new DateTime('24 hours');
    var_dump($dtAdd->format('Y-m-d H:m:s'));die;
    ?>
    

提交回复
热议问题