Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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
date("H:i", strtotime("11:30 +15 minutes"));
Add a comment
Try this way:
$time = "11:30"; $minutes = 15; $time = strtotime($time) + $minutes * 60; echo date("H:i", $time);
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);
I think you can do what your asking for using the built in PHP methods mktime and date_add.
Required, but never shown
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.
Explore related questions
See similar questions with these tags.