This article mainly introduces how to display the website running time in php. If you need a friend, you can refer to the following nonsense and directly go to the code.
The Code is as follows:
// Set the time zone
Date_default_timezone_set ('Asia/Shanghai ');
/**
* Second to second, in the format of year month day hour minute second
*
* @ Author wangyupeng129@126.com
* @ Param int $ time
* @ Return array | boolean
*/
Function Sec2Time ($ time ){
If (is_numeric ($ time )){
$ Value = array (
"Years" => 0, "days" => 0, "hours" => 0,
"Minutes" => 0, "seconds" => 0,
);
If ($ time> = 31556926 ){
$ Value ["years"] = floor ($ time/31556926 );
$ Time = ($ time % 31556926 );
}
If ($ time> = 86400 ){
$ Value ["days"] = floor ($ time/86400 );
$ Time = ($ time % 86400 );
}
If ($ time> = 3600 ){
$ Value ["hours"] = floor ($ time/3600 );
$ Time = ($ time % 3600 );
}
If ($ time> = 60 ){
$ Value ["minutes"] = floor ($ time/60 );
$ Time = ($ time % 60 );
}
$ Value ["seconds"] = floor ($ time );
Return (array) $ value;
} Else {
Return (bool) FALSE;
}
}
// Time when this site was created
$ Site_create_time = strtotime ('2017-05-22 00:00:00 ');
$ Time = time ()-$ site_create_time;
$ Uptime = Sec2Time ($ time );
?>
Run on this site: Year Days Hours Minute Seconds