首頁  >  文章  >  後端開發  >  將linux運行時間格式成易讀格式的php程式碼

將linux運行時間格式成易讀格式的php程式碼

WBOY
WBOY原創
2016-07-25 08:45:491137瀏覽
  1. $exec = shell_exec('uptime');
  2. $uptime = explode(' up ', $exec);
  3. $uptime = explode(',', $uptime[1]);
  4. if (strpos($uptime[0], 'day')) {
  5. $time = explode(':', $uptime[1]);
  6. echo('Current system uptime is ' . $uptime[0]. ', ' . $time[0] . ' hours, ' . $time[1] . ' minutes');
  7. } elseif (strpos($uptime[0], ':')) {
  8. $time = explode(':', $uptime[0]);
  9. echo('Current system uptime is ' . $time[0] . ' hours, ' . $time[1] . ' minutes');
  10. } else {
  11. $time = explode(' ', $uptime[0]);
  12. echo('Current system uptime is ' . $time[0] . ' minutes');
  13. }
  14. ?>
复制代码

易讀, linux, php


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn