php查看系统启动时间长短
root@~# uptime;cat /proc/uptime
3:57pm up 381 days 5:09, 1 user, load average: 0.30, 0.36, 0.28
32936982.68 12372643.36
root@~#
//系统启动时间计算.
$UPTIME=32936982.68;
$DAY = floor(($UPTIME / 86400)*1.0) ;
$cal_day = $DAY * 86400 ;
$cal_hour = $UPTIME - $cal_day ;
$hour = floor(($cal_hour / 3600)*1.0) ;
if ($hour < 10) {
$hour = "0".$hour ;
}
$cal_tmp = $hour * 3600 ;
$cal_min = $cal_hour - $cal_tmp ;
$min = floor(($cal_min / 60)*1.0) ;
if ($min < 10) {
$min = "0".$min ;
}
$cal_sec = $min * 60 ;
$sec = floor(($cal_min - $cal_sec)*1.0) ;
if ($min < 10) {
$sec = "0".$sec ;
}
$ServerUptime = $DAY." 天, ".$hour.":".$min.":".$sec ;
?>
=======================结果输出========================
结果输出: 381 天, 05:09:042
阅读(2180) | 评论(0) | 转发(0) |