的/ proc /运行时间
此文件包含两个数字:系统的正常运行时间(秒)以及空闲进程所花费的时间(秒).
<?php
function get_boottime() {
$tmp = explode(' ', file_get_contents('/proc/uptime'));
return time() - intval($tmp[0]);
}
echo get_boottime() . "\n";
Run Code Online (Sandbox Code Playgroud)