Jump to content

Getting uptime in seconds


jordanwb

Recommended Posts

So do a bunch of parsing:

<?php
$uptime = shell_exec('uptime');
$up_exp = array_map('trim',explode(',',$uptime));
list(,,$days) = explode(' ',$up_exp[0]);
list($h,$m) = explode(':',$up_exp[1]);
$days_sec = ($days * 86400) + ($h * 3600) + ($m * 60);
echo $days_sec;
?>

 

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.