>i have variables $Start, $End each with a timestamp 2 hours apart
>(20020707140000, 20020707160000) respectively....
  01234567890123
>
>How do i calculate those to timestamps to get the answer 2?????
>
>I've tried working them into unix timestamps and then calculating but no
>luck...
>
>any one got any ideas ??

I'm guessing these are coming from MySQL... If so, you can subtract the two
in MySQL much easier/faster than PHP...

http://mysql.com/

If not:

$s = mktime(substr($Start, 8, 2), substr($Start, 10, 2), substr($Start, 12,
2), substr($Start, 4, 2), substr($Start, 6, 2), substr($Start, 0, 4));
$e = mktime(substr($End, 8, 2), substr($End, 10, 2), substr($End, 12, 2),
substr($End, 4, 2), substr($End, 6, 2), substr($End, 0, 4));

$delta = $e - $s;


At this point, it boils down to the question -- Will it ever be, like,
*DAYS* instead of hours, or, more importantly, *MONTHS*?

Because as soon as you get into "months" or larger time units, it gets
complicated...

Until then, you can divide by 60, or 60*60, or 60*60*24 to get the number of
minutes, hours, days respectively...

-- 
Like Music?  http://l-i-e.com/artists.htm


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to