Mmmm,
Do you know what I would do?
I'd store the duration as text, maybe, if the duration could be different, use a drop down form to set the duration and store the result.
Then use the strtotime function to add the start time and the duration together
Here's the php manual example:
Example 1. strtotime() examples
<?php
echo strtotime ("now"), "\n";
echo strtotime ("10 September 2000"), "\n";
echo strtotime ("+1 day"), "\n";
echo strtotime ("+1 week"), "\n";
echo strtotime ("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime ("next Thursday"), "\n";
echo strtotime ("last Monday"), "\n";
?>
We can see that we could add 20 minites to a time, example:
echo strtotime ("+20 minutes"), "\n";
so why not use this?
We also have another built in function the date function, which will let use add units to the date.
I feel another example coming on....
Example 3. date() and mktime() example
<?php
$tomorrow = mktime (0,0,0,date("m") ,date("d")+1,date("Y"));
$lastmonth = mktime (0,0,0,date("m")-1,date("d"), date("Y"));
$nextyear = mktime (0,0,0,date("m"), date("d"), date("Y")+1);
?>
Has the penny dropped yet?
Have a think about this, maybe use both functions to achive the desired result.
Hope this helps...
🙂
PS, it's always fun to read the manual
😃