note 27025 added to function.posix-times
| From: | rossz+php at vamos-wentworth dot org | Date: | Wed, 20 Nov 2002 19:42:26 +0000 |
| Subject: | note 27025 added to function.posix-times | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-39766@lists.php.net to get a copy of this message | ||
This function will return the system uptime as a human readable string such as "172 days, 18
hours, 15 minutes". I didn't bother to handle singular so the grammar could be a bit off,
e.g. 1 hours.
function uptime() {
if (!$times = posix_times()) {
return ("unknown");
} else {
$now = $times['ticks'];
$days = intval($now / (60*60*24*100));
$remainder = $now % (60*60*24*100);
$hours = intval($remainder / (60*60*100));
$remainder = $remainder % (60*60*100);
$minutes = intval($remainder / (60*100));
return ("$days days, $hours hours, $minutes minutes");
}
}
--
http://www.php.net/manual/en/function.posix-times.php
http://master.php.net/manage/user-notes.php?action=edit+27025
http://master.php.net/manage/user-notes.php?action=delete+27025
http://master.php.net/manage/user-notes.php?action=reject+27025