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
Release: 2016-05-16 16:47:44
Original
1303 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template