[PHP] Re: Time to Calculate Time

2002-07-09 Thread Richard Lynch

i have variables $Start, $End each with a timestamp 2 hours apart
(2002070714, 2002070716) 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




[PHP] Re: Time to Calculate Time

2002-07-08 Thread Lord Loh.

?php
function getmicrotime(){
list($usec, $sec) = explode( ,microtime());
$time=$sec+$usec;
return $time;
}

$start=getmicrotime();
echo wasting time...br;
$i=0;
do{
$i++;
}while($i=100);
$stop=getmicrotime();
$difference=($stop-$start)/3600;
echo $start.br.$stop.br.$difference. Hours;
?

Does this help...

- Lord Loh



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