1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/linuxdash_ynh.git synced 2024-09-03 19:36:07 +02:00
linuxdash_ynh/sources/sh/uptime.php
2014-06-02 13:38:03 +02:00

25 lines
563 B
PHP

<?php
$totalSeconds = shell_exec("/usr/bin/cut -d. -f1 /proc/uptime");
$totalMin = $totalSeconds / 60;
$totalHours = $totalMin / 60;
$days = floor($totalHours / 24);
$hours = floor($totalHours - ($days * 24));
$min = floor($totalMin - ($days * 60 * 24) - ($hours * 60));
$formatUptime = '';
if ($days != 0) {
$formatUptime .= "$days days ";
}
if ($hours != 0) {
$formatUptime .= "$hours hours ";
}
if ($min != 0) {
$formatUptime .= "$min minutes";
}
header('Content-Type: application/json; charset=UTF-8');
echo json_encode($formatUptime);