Let's talk about the code.
Copy codeThe Code is as follows:
<? Php
// 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: <span style = "color: red;"> <? Php echo $ uptime ['ears'];?> Year <? Php echo $ uptime ['days'];?> Day <? Php echo $ uptime ['hours'];?> Hour <? Php echo $ uptime ['minutes '];?> Score <? Php echo $ uptime ['seconds'];?> Seconds </span>