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

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

    In same code use strtotime() its working.

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

提交回复
热议问题