Time calculation in php (add 10 hours)?

后端 未结 7 872
悲哀的现实
悲哀的现实 2020-12-03 03:18

I get the time:

$today = time();
$date = date(\'h:i:s A\', strtotime($today));

if the current time is \"1:00:00 am\", how do i add 10 more

7条回答
  •  离开以前
    2020-12-03 03:36

    You can simply make use of the DateTime class , OOP Style.

    add(new DateInterval('PT10H'));
    echo $date->format('H:i:s a'); //"prints" 11:00:00 a.m
    

提交回复
热议问题