Create Variable in PHP Equal to Current Time Minus One Hour

前端 未结 9 1316
青春惊慌失措
青春惊慌失措 2020-12-11 15:12

In PHP, how could I create a variable called $livetime that equals the current time minus 1 hour?

9条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-11 15:30

    convert your date to strtotime and then subtract one hour from it

    $now =  date('Y-m-d H:i:s');
    $time   = strtotime($now);
    $time   = $time - (60*60); //one hour
    $beforeOneHour = date("Y-m-d H:i:s", $time);
    

提交回复
热议问题