php将linux运行时间转换格式的简单示例

前端之家收集整理的这篇文章主要介绍了php将linux运行时间转换格式的简单示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
PHP将linux运行时间转换成更好看的格式感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编两巴掌来看看吧!

/**
 * PHP将linux运行时间转换成更好看的格式
 *
 * @param 
 * @arrange 512-笔记网: www.512Pic.com
 **/
<?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');
}

/***   来自编程之家 jb51.cc(jb51.cc)   ***/
原文链接:https://www.f2er.com/php/528349.html

猜你在找的PHP相关文章