|
Posted by Steve on 10/01/07 14:17
"Julius" <julius.ehrlich@googlemail.com> wrote in message
news:1191246555.184747.240030@n39g2000hsh.googlegroups.com...
> Hej dudes,
>
> I need to calc the difference between two timestamps / dates ...
>
> For example what i need to calculate:
>
> Date 1: 2007.11.06 - 20:13:04
> Date 2: 2007.11.07 - 21:13:04
>
> Difference: 1 day, 1hour
>
> Very simple in php ..
>
> but how do i calculate the difference between the following values:
>
> Date 1: 2007.11.06 - 20:13:04
> Date 2: 2007.11.08 - 03:13:04
there is no 'difference'. you want to subtract those hours/minutes/seconds
from 2007-11-06...right?
$stamp = strtotime('2007-11-06');
$minus = explode(':', '20:13:04');
foreach ($minus as $increment => $value)
{
switch($increment)
{
case 0: $increment = ' hours'; break;
case 1: $increment = ' minutes'; break;
case 2: $increment = ' seconds'; break;
}
$stamp = strtotime('-' . $value . $increment, $stamp);
}
Navigation:
[Reply to this message]
|