Created
January 23, 2014 00:01
-
-
Save vibbow/8570137 to your computer and use it in GitHub Desktop.
优雅 (蛋疼) 的获取Linux开机时长
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$uptime = file_get_contents('/proc/uptime'); // 1164820.24 4655047.46; | |
$upsecond = (int)explode(' ', $uptime)[0]; | |
$datediff = date_diff(date_create(), date_create("{$upsecond} second ago"), true); | |
echo $datediff->y . "\r\n"; | |
echo $datediff->m . "\r\n"; | |
echo $datediff->d . "\r\n"; | |
echo $datediff->h . "\r\n"; | |
echo $datediff->i . "\r\n"; | |
echo $datediff->s . "\r\n"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment