Jump to content

[SOLVED] Adding minutes to a timestamp


assgar

Recommended Posts

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
Share on other sites

 

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.