Alex Rivera | Logout

Time calculation in php (add 10 hours)?

Asked 2009-11-03T07:08:19.027
27

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 hours to become 11:00:00 am??

Edit
Report

2 Answers

23
$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)

answered 2009-11-03T07:16:45.077
5
$date = date('h:i:s A', strtotime($today . " +10 hours"));
answered 2009-11-03T07:11:08.910

Your Answer