将linux运行时间格式成易读格式的php代码

WBOY
发布: 2016-07-25 08:45:49
原创
1141 人浏览过
  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


来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板