如何将Linux运行时间转换为易读格式的PHP代码?

更新于
2026-09-27 20:01:03
0阅读来源:SEO问题
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计73个文字,预计阅读时间需要1分钟。

如何将Linux运行时间转换为易读格式的PHP代码?

php

如何将Linux运行时间转换为易读格式的PHP代码?

<?php $exec = shell_exec('uptime'); $uptime = explode(' up ', $exec); $uptime = explode(',', $uptime[1]); if (strpos($uptime[0], 'day')) { $time = explode(':', $uptime[1]); echo('Current system uptime is ' . $uptime[0]. ', ' . $time[0] . ' hours, ' . $time[1] . ' minutes'); } elseif (strpos($uptime[0], ':')) { $time = explode(':', $uptime[0]); echo('Current system uptime is ' . $time[0] . ' hours, ' . $time[1] . ' minutes'); } else { $time = explode(' ', $uptime[0]); echo('Current system uptime is ' . $time[0] . ' minutes'); } ?>

标签:PHP代码

本文共计73个文字,预计阅读时间需要1分钟。

如何将Linux运行时间转换为易读格式的PHP代码?

php

如何将Linux运行时间转换为易读格式的PHP代码?

<?php $exec = shell_exec('uptime'); $uptime = explode(' up ', $exec); $uptime = explode(',', $uptime[1]); if (strpos($uptime[0], 'day')) { $time = explode(':', $uptime[1]); echo('Current system uptime is ' . $uptime[0]. ', ' . $time[0] . ' hours, ' . $time[1] . ' minutes'); } elseif (strpos($uptime[0], ':')) { $time = explode(':', $uptime[0]); echo('Current system uptime is ' . $time[0] . ' hours, ' . $time[1] . ' minutes'); } else { $time = explode(' ', $uptime[0]); echo('Current system uptime is ' . $time[0] . ' minutes'); } ?>

标签:PHP代码