php查看系统启动时间长短
时间:2010-08-07 来源:wood016
php查看系统启动时间长短
[email protected]:~# 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
[email protected]:~#
<?php
//系统启动时间计算.
$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 ;
?>
<?php echo '结果输出: ' . $ServerUptime ; ?>
=======================结果输出========================
结果输出: 381 天, 05:09:042
[email protected]:~# 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
[email protected]:~#
<?php
//系统启动时间计算.
$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 ;
?>
<?php echo '结果输出: ' . $ServerUptime ; ?>
=======================结果输出========================
结果输出: 381 天, 05:09:042
相关阅读 更多 +