欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php實(shí)例分享之實(shí)現(xiàn)顯示網(wǎng)站運(yùn)行時(shí)間

 更新時(shí)間:2014年05月20日 08:39:05   作者:  
這篇文章主要介紹了php實(shí)現(xiàn)顯示網(wǎng)站運(yùn)行時(shí)間,需要的朋友可以參考下

廢話不多說(shuō),直接上代碼。

復(fù)制代碼 代碼如下:

<?php
// 設(shè)置時(shí)區(qū)
date_default_timezone_set('Asia/Shanghai');
/**
 * 秒轉(zhuǎn)時(shí)間,格式 年 月 日 時(shí) 分 秒
 *
 * @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;
 }
}

// 本站創(chuàng)建的時(shí)間
$site_create_time = strtotime('2013-05-22 00:00:00');
$time = time() - $site_create_time;
$uptime = Sec2Time($time);
?>

本站運(yùn)行:<span style="color:red;"><?php echo $uptime['years']; ?>年<?php echo $uptime['days']; ?>天<?php echo $uptime['hours']; ?>小時(shí)<?php echo $uptime['minutes']; ?>分<?php echo $uptime['seconds']; ?>秒</span>

相關(guān)文章

最新評(píng)論