a little math

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



maybe someone can figure why sometimes i get negative values for seconds..

$job['finished'] and $job['finished'] are both unix timestamp.
i subtract both to get how many seconds some thing took.. well you should be able to read the rest. sometimes it works fine but other times i get negative seconds.


$job['run_time']  = ($job['finished'] - $job['started']);

$minutes = number_format($job['run_time'] / 60, 0, '', '');

// seconds left after calculating minutes
$seconds = (($job['run_time']- 60) * $minutes);

$job['runtime'] = $minutes . ' mins ' . $seconds . ' secs';

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux