This is the effect I added last night,
Divided into three parts:
1. The site has been stable operation of the implementation of how many days:
Just copy the code below to the background where you want to add it.
| 123456789 |
本站已稳定运行了<strong><script language="JavaScript" type="text/javascript">var urodz= new Date("9/25/2015");var now = new Date();var ile = now.getTime() - urodz.getTime();var dni = Math.floor(ile / (1000 * 60 * 60 * 24));document.write(+dni)</script></strong>天 |
2. Date of the month, day of the week to achieve:
Just copy the code below to the background where you want to add it.
| 1234567891011121314 |
<script>var mydate=new Date()var year=mydate.getYear()if (year < 1000)year+=1900var day=mydate.getDay()var month=mydate.getMonth()var daym=mydate.getDate()if (daym<10)daym="0"+daymvar dayarray=new Array("星期天","星期一","星期二","星期三","星期四","星期五","星期六")var montharray=new Array("1","2","3","4","5","6","7","8","9","10","11","12")document.write(year+"年"+montharray[month]+"月"+daym+"日"+" "+dayarray[day])</script> |
3. Hours and seconds and the implementation of the refresh effect:
First copy the following code to the background you want to add the location,
| 12345678910111213141516171819202122 |
<div id="timetxt"></div><script> function startTime(){ var today=new Date(); var h=today.getHours(); var m=today.getMinutes(); var s=today.getSeconds(); h=checkTime(h); m=checkTime(m); s=checkTime(s); document.getElementById("timetxt").innerHTML=h+"时"+m+"分"+s+"秒"; t=setTimeout(function(){ startTime(); },1000); } function checkTime(i){ if(i<10){ i="0"+i; } return i; }</script> |
And then find it in header.php and add it to the inside.
As follows:
Then save it. Refresh the page and you'll see the effect.
Get.
This site has been stable operation of XX days, Web time display function implementation method