datetime new DateTime datetime- setTime server uptime if server uptime

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
$datetime = new DateTime();
$datetime->setTime(0, 0, $server['uptime']);
if($server['uptime'] >= 172800)
$uptime = $datetime->format('d').' '.$language->get('days');
else if($server['uptime'] >= 86400 && $server['uptime'] < 172800)
$uptime = $datetime->format('d').' '.$language->get('day');
else if($server['uptime'] >= 18000) // 5 hours
$uptime = $datetime->format('H').' '.$language->get('hours');
else if($server['uptime'] >= 7200) // 2 hours
$uptime = $datetime->format('H').' '.$language->get('hour2');
else if($server['uptime'] >= 3600) // 1 hour
$uptime = $datetime->format('H').' '.$language->get('hour');
else if($server['uptime'] >= 300) // 5 min
$uptime = $datetime->format('i').' '.$language->get('minutes');
else if($server['uptime'] >= 120) //
$uptime = $datetime->format('i').' '.$language->get('minute2');
else if($server['uptime'] >= 60) //
$uptime = $datetime->format('i').' '.$language->get('minute');
else if($server['uptime'] <= 59) //
$uptime = $datetime->format('s').' '.$language->get('seconds');