tags:

views:

58

answers:

4

i have a value store in variables as 11:30.

I need to add a minutes to this variable..Example, adding 15 minutes to make it 11:45

can i do that ? i tried to use time() but it will give current time... but i want to add time to the specified variable

A: 

Here's a way:

$str = "11:30";
list($h, $m) = explode(":", $str);
$tm = mktime($h, $m + 15, 0, 0, 0, 0);
echo date("H:i", $tm);
nc3b
cheers nc3b... its exactly wat i m looking for...
redcoder
A: 

I think you can do what your asking for using the built in PHP methods mktime and date_add.

jaltiere
+1  A: 

Try this way:

$time = "11:30";
$minutes = 15; 
$time = strtotime($time) + $minutes * 60;
echo date("H:i", $time);
Bar
+2  A: 
date("H:i", strtotime("11:30 +15 minutes"));
Alexander Konstantinov