assgar Posted August 9, 2007 Share Posted August 9, 2007 Hi How can I add 15 minutes to the previous event time (timestamp) to get the next event time. Note: This event time is not in a table. Straight forward adding the two values will probly not provide the correct result. I can get the correct time with Mysql addtime($time, $duration) but that is only good if the if info is in a table. Thanks <?php $time = "09:00:00";//timestamp hh:mm:ss $duration = 00:15:00;//enent duration hh:mm:ss $next_time = $event_time + $event_duration; ?> Link to comment https://forums.phpfreaks.com/topic/63987-solved-adding-minutes-to-a-timestamp/ Share on other sites More sharing options...
utexas_pjm Posted August 9, 2007 Share Posted August 9, 2007 <?php $timestamp = strtotime( "2007-08-08 09:00:00"); $deltaTimestamp = strtotime("+15 minutes", $timestamp); print date( 'Y-m-d H:i:s', $deltaTimestamp ); ?> http://us2.php.net/strtotime Best, Patrick Link to comment https://forums.phpfreaks.com/topic/63987-solved-adding-minutes-to-a-timestamp/#findComment-318973 Share on other sites More sharing options...
assgar Posted August 9, 2007 Author Share Posted August 9, 2007 Hi Patrick You are great! Thanks for the suggestion. This is the final code that solved the problem. <? $event_time = 09:00:00 $event_length = 15; $timestamp = strtotime("$event_time"); $etime = strtotime("+$event_length minutes", $timestamp); $next_time = date('H:i:s', $etime); ?> Link to comment https://forums.phpfreaks.com/topic/63987-solved-adding-minutes-to-a-timestamp/#findComment-319050 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.