Home > Backend Development > PHP Tutorial > PHP converts linux runtime into a better-looking format

PHP converts linux runtime into a better-looking format

WBOY
Release: 2016-07-25 08:44:16
Original
1263 people have browsed it

php converts linux running time into a better-looking format

  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. ?>
Copy code

Convert to, php, linux


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template