Add 30 seconds to the time with PHP

后端 未结 8 2058
旧时难觅i
旧时难觅i 2021-02-05 03:29

How can I add 30 seconds to this time?

$time = date(\"m/d/Y h:i:s a\", time());

I wasn\'t sure how to do it because it is showing lots of diffe

8条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-05 04:04

    $time = date("m/d/Y h:i:s", time());
    $ts = strtotime($time);
    $addtime = date("m/d/Y h:i:s", mktime(date("h", $ts),date("i", $ts),date("s", $ts)+30,date("Y", $ts),date("m", $ts),date("d", $ts));
    

    Would be a more explained version of all of the above.

提交回复
热议问题