Zachary Antolak wrote:
Actually, the normal times returned are usually around 0.1xxxxx and
the strange ones are around -0.8xxxxx. They're like a normal value,
but -1. So, I made a test for it:
if ($this->calc_time < 0)
{
$this->calc_time = $this->calc_time + 1;
}
It seems to work. Is this okay to use?
NO! It is *NOT* okay to use if you want valid data!
Copied from
http://www.php.net/microtime
--------
Description
string microtime ( void)
Returns the string "msec sec" where sec is the current time
measured in the number of seconds since the Unix Epoch
(0:00:00 January 1, 1970 GMT), and msec is the microseconds
part. This function is only available on operating systems
that support the gettimeofday() system call.
Both portions of the string are returned in units of seconds.
========
So, right now if I do
<?php
$a = microtime();
echo '[ ', $a, ' ]';
?>
I get
[ 0.18475200 1057352986 ]
and in exactly five seconds I'd get
[ 0.18475200 1057352991 ]
so now I do
<?php
$first = '0.18475200 1057352986';
$second = '0.18475200 1057352991';
echo '[ ', $second - $first, ' ]';
?>
to get
[ 0 ]
I guess this isn't what you want :)
Check the very first example on the PHP manual to transform the string
"0.18475200 1057352986" to the float 1057352986.18475200
Happy Coding !!
--
"Yes, I'm positive."
"Are you sure?"
"Help, somebody has stolen one of my electrons!"
Two atoms are talking: