suresh64633 Posted September 11, 2009 Share Posted September 11, 2009 How do i add 30 minutes to my time in PHP Time are like 10:00 AM, 12.30 AM,02:00 PM. Link to comment https://forums.phpfreaks.com/topic/173877-solved-how-do-i-add-30-minutes-to-my-time/ Share on other sites More sharing options...
syed Posted September 11, 2009 Share Posted September 11, 2009 Convert your time to a timestamp, then add 1800 seconds to the timestamp then convert it back to a formatted time. Link to comment https://forums.phpfreaks.com/topic/173877-solved-how-do-i-add-30-minutes-to-my-time/#findComment-916584 Share on other sites More sharing options...
suresh64633 Posted September 11, 2009 Author Share Posted September 11, 2009 Got the Answer: $startTime = 07:00 AM for($loop=1;$loop<=5;$loop++) { $event_length = 30*$loop; $timestamp = strtotime("$startTime"); $etime = strtotime("+$event_length minutes", $timestamp); echo $next_time = date('h:i A', $etime)."<br />"; } Link to comment https://forums.phpfreaks.com/topic/173877-solved-how-do-i-add-30-minutes-to-my-time/#findComment-916592 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.