Arne Gemsa wrote:
Hi,
I want to get a starttime. To get this I have to subtract the runtime from
a unit e.g. 08:40:15 from a date e.g. 2007-03-29 16:48:30. So the
starttime is 2007-03-29 08:08:15.
Is there any function in php to do so, or must I do it by myself?
Hi,
Easiest way I know of (that also works in almost any language I have seen)
is simply cast your startdate to a UTS (Unix Time Stamp): The number of
seconds that passed since 1970.
--Look at function strtotime():
$EndtimeUTS = strtotime("2007-03-29 16:48:30");
Then calculate the number of seconds in your interval.
I don't know of a function (might very well exists), but you could simply do
something like this:
$interval = "08:40:15";
list($hours,$mi nutes,$secs) = explode(":",$in terval);
$secsInInterval = $secs + $minutes*60 + $hours*60*60;
Subtract the latter from the first.
$starttimeUTS = $EndtimeUTS-$secsInInterval ;
Cast the resulting UTS to a date.
-->lookup function date()
$formattedStart Time = date("Y-m-d H:i:s",$startti meUTS);
Not tested, could contain typos and bugs. :P
>
thx
Regards,
Erwin Moller