mirror of
https://github.com/YunoHost-Apps/linuxdash_ynh.git
synced 2024-09-03 19:36:07 +02:00
25 lines
563 B
PHP
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);
|