Time calculation in php (add 10 hours)?

后端 未结 7 880
悲哀的现实
悲哀的现实 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:28

    $tz = new DateTimeZone('Europe/London');
    $date = new DateTime($today, $tz);
    $date->modify('+10 hours');
    // use $date->format() to outputs the result.
    

    see DateTime Class (PHP 5 >= 5.2.0)

提交回复
热议问题