Home >Web Front-end >JS Tutorial >PHP example sharing implementation to display website running time_javascript skills

PHP example sharing implementation to display website running time_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:47:441299browse

Without further ado, let’s get straight to the code.

Copy code The code is as follows:

// Set time zone
date_default_timezone_set('Asia/Shanghai');
/**
* Seconds to time, format year, month, day, hour, minute and 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 = ($time1556926);
}
if($time >= 86400){
$value["days"] = floor($time/86400);
$time = ($time�400);
}
if($time >= 3600){
$value["hours"] = floor($time/3600);
$time = ($time600);
}
if ($time >= 60){
$value["minutes"] = floor($time/60);
$time = ($time`);
}
$value[ "seconds"] = floor($time);
return (array) $value;
}else{
return (bool) FALSE;
}
}

//The time when this site was created
$site_create_time = strtotime('2013-05-22 00:00:00');
$time = time() - $site_create_time;
$uptime = Sec2Time($time);
?>

This site runs: yeardayshoursminutesSeconds

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn