0

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

4 Answers 4

2
date("H:i", strtotime("11:30 +15 minutes"));
Sign up to request clarification or add additional context in comments.

Comments

1

Try this way:

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

Comments

0

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);

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.