添加网站运行时间

效果可见本网站底部,精确到秒。
修改你初建网站的时间。我的是二零零七年十一月八日,已经运行十多年了,不信大家看文章归档。代码如下:

<p align="center"><span id="runtime_span"></span>
<script type="text/javascript">function show_runtime(){window.setTimeout("show_runtime()",1000);X=new 
Date("11/08/2007 15:28:00");
Y=new Date();T=(Y.getTime()-X.getTime());M=24*60*60*1000;
a=T/M;A=Math.floor(a);b=(a-A)*24;B=Math.floor(b);c=(b-B)*60;C=Math.floor((b-B)*60);D=Math.floor((c-C)*60);
runtime_span.innerHTML="本站已艰难运行"+A+"天"+B+"小时"+C+"分"+D+"秒"}show_runtime();</script><p>

2018.12.9更新年月日显示模式,代码如下:

<?php
date_default_timezone_set('Asia/Shanghai');
function Sec2Time($time){if(is_numeric($time)){$value = array("y"=>0,"m" =>0,"d" =>0,"h" =>0,"i" =>0,"s" =>0,);
if($time>=31556926){$value["y"] = floor($time/31556926);$time=($time%31556926);}
if($time>=2592000){$value["m"]=floor($time/2592000);$time=($time%2592000);}
if($time>=86400){$value["d"]=floor($time/86400);$time=($time%86400);}
if($time>=3600){$value["h"]=floor($time/3600);$time = ($time%3600);}
if($time>=60){$value["i"] = floor($time/60);$time = ($time%60);}
$value["seconds"]=floor($time);return (array) $value;}else{return (bool) FALSE;}}
$site_create_time = strtotime('2007-11-08');
$time = time() - $site_create_time;
$sltime = Sec2Time($time);
echo '本站已艰难运行';if($sltime['y']!='0'){echo $sltime['y'].'年';}if($sltime['m']=='0' && $sltime['d']=='0'){echo '整';}if($sltime['m']!='0'){echo $sltime['m'].'月';}else{if($sltime['d']!='0'){echo '零';}}if($sltime['d']!='0'){echo $sltime['d'].'天';}?>

一衰人走在毁人不倦的不归路途。父不父,夫不夫,子不子,师不师,我之谓也。

传说看完文章评个论是高尚品德

随机一篇看看手气咯
狠狠的抽打博主 支付宝微信打赏