KyleH112
Apprentice
Posts: 18
Likes Given: 0
Likes Received: 6 in 4 posts
Joined: Oct 2012
Reputation: 0
|
RE: spherestatusbase
(09-06-2013 09:49 PM)Leonidas Wrote: I'm trying to show an uptime on my server status, I read on the wiki and saw I could use %TIME%, but it said it shows the uptime in tenths of a second. How would i do this so it would show the uptime in minutes, hours, or even days?
Thanks for any help!
If your hosting your server from a Windows machine and running PHP you can use something like this... What this script does is pulls your computers/servers pagefile.sys file which stores your computers/system/servers information and it will extract the uptime in this format ( #Days, #Hours, ##Minutes, ##Seconds) and will also show the last time the system was rebooted.
Code:
<?php
$pagefile = 'c:\pagefile.sys';
function ifif ($value, $true, $false)
{
if ($value == 0)
{
return $false;
}
else
{
return $true;
}
}
$upsince = filemtime($pagefile);
$gettime = (time() - filemtime($pagefile));
$days = floor($gettime / (24 * 3600));
$gettime = $gettime - ($days * (24 * 3600));
$hours = floor($gettime / (3600));
$gettime = $gettime - ($hours * (3600));
$minutes = floor($gettime / (60));
$gettime = $gettime - ($minutes * 60);
$seconds = $gettime;
$days = ifif($days != 1, $days . ' days', $hours . ' day');
$hours = ifif($hours != 1, $hours . ' hours', $hours . ' hour');
$minutes = ifif($minutes != 1, $minutes . ' minutes', $minutes . ' minute');
$seconds = ifif($seconds != 1, $seconds . ' seconds', $seconds . ' second');
echo '<font color="red">Uptime:</font> ' . $days . ' ' . $hours . ' ' . $minutes . ' ' . $seconds;
echo '<br /> <font color="red"> Rebooted:</font> ' . date('l. F jS, Y. h:i a', $upsince);
?>
|
|
10-09-2013 02:59 PM |
|
|