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

2015-01-31 0 429
将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 将linux运行时间格式成易读格式的php代码 http://www.ox520.com/7363.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务