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

后端 未结 10 1394
我寻月下人不归
我寻月下人不归 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:18

    you can do this in many ways...

    echo date('Y-m-d H:i:s',strtotime('-24 hours')); // "i" for minutes with leading zeros
    

    OR

    echo date('Y-m-d H:i:s',strtotime('last day')); // 24 hours (1 day)
    

    Output

    2013-07-17 10:07:29
    

提交回复
热议问题