Nonsense not much to say, directly on the code.
Copy Code code as follows:
<?php
Set time zone
Date_default_timezone_set (' Asia/shanghai ');
/**
* Seconds turn time, format month day time seconds
*
* @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;
}
}
The time of the site creation
$site _create_time = Strtotime (' 2013-05-22 00:00:00 ');
$time = Time ()-$site _create_time;
$uptime = Sec2time ($time);
?>
This station runs: <span style= "color:red;" ><?php echo $uptime [' years '];?> year <?php echo $uptime [' days '];?> day <?php echo $uptime [' hours '];?> hour & lt;? PHP echo $uptime [' minutes '];?> <?php echo $uptime [' seconds '];?> sec </span>