Create Variable in PHP Equal to Current Time Minus One Hour

前端 未结 9 1311
青春惊慌失措
青春惊慌失措 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:21

    You could use the date_create function along with the date_sub function like I have shown here below: -

    $currentTime = date_create(now());
    $modifyTime = date_sub($currentTime,date_interval_create_from_date_string("1 hour"));
    $liveTime = $modifyTime->format('Y-m-d H:i:s');
    

提交回复
热议问题