public function uptime($option = '-p')
    {
        if ($this->host_os === 'WINDOWS') {
            $wmi = new \COM("winmgmts:\\\\.\\root\\cimv2");
            $os = $wmi->ExecQuery("SELECT * FROM Win32_OperatingSystem");

            foreach ($os as $o) {
                $date = explode('.', $o->LastBootUpTime);

                $uptime_date = DateTime::createFromFormat('YmdHis', $date[0]);
                $now = DateTime::createFromFormat('U', time());
                $interval = $uptime_date->diff($now);
                $uptime = $interval->format('up %a days, %h hours, %i minutes');
            }
        } else {
            $uptime = shell_exec('uptime '.$option);
        }
        return trim($uptime);
    }
public function uptime($option = '-p')
    {
        if ($this->host_os === 'WINDOWS') {
            $wmi = new \COM("winmgmts:\\\\.\\root\\cimv2");
            $os = $wmi->ExecQuery("SELECT * FROM Win32_OperatingSystem");

            foreach ($os as $o) {
                $date = explode('.', $o->LastBootUpTime);

                $uptime_date = DateTime::createFromFormat('YmdHis', $date[0]);
                $now = DateTime::createFromFormat('U', time());
                $interval = $uptime_date->diff($now);
                $uptime = $interval->format('up %a days, %h hours, %i minutes');
            }
        } else {
            $uptime = shell_exec('uptime '.$option);
        }
        return trim($uptime);
    }
public function uptime ( $ option = '-p' ) { if ( $ this -> host_os === 'WINDOWS' ) { $ wmi = new \ COM ( "winmgmts:\\\\.\\root\\cimv2" ) ; $ os = $ wmi -> ExecQuery ( "SELECT * FROM Win32_OperatingSystem" ) ; foreach ( $ os as $ o ) { $ date = explode ( '.' , $ o -> LastBootUpTime ) ; $ uptime_date = DateTime :: createFromFormat ( 'YmdHis' , $ date [ 0 ] ) ; $ now = DateTime :: createFromFormat ( 'U' , time ( ) ) ; $ interval = $ uptime_date -> diff ( $ now ) ; $ uptime = $ interval -> format ( 'up %a days, %h hours, %i minutes' ) ; } } else { $ uptime = shell_exec ( 'uptime ' . $ option ) ; } return trim ( $ uptime ) ; }
Get system uptime
Get system uptime