*/
trait System {
/**
- * get uptime based on online (connection) time
+ * get uptime based on last reboot
*
* @return string
*/
public function getUptime () {
- $data = $this->getData('Overview');
- $data = $this->getValues($data);
+ $lastReboot = $this->getLastReboot();
+
+ $dtF = new DateTime("@0");
+ $dtT = new DateTime("@".$lastReboot);
- return $data['days_online'];
+ return $dtF->diff($dtT)->format('%a days, %h hours, %i minutes and %s seconds');
}
/**
}
}
+ /**
+ * get Last Reboot time
+ *
+ * @return int
+ */
+ public function getLastReboot () {
+ $response = $this->sendRequest("data/Reboot.json");
+ $response = $this->getValues($response);
+
+ $lastReboot = time() - strtotime($response['reboot_date']." ".$response['reboot_time']);
+
+ return $lastReboot;
+ }
+
/**
* reset the router to Factory Default
* not tested