This site has been stable operation of XX days, Web time display function implementation method

Source: Internet
Author: User

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.

1 onload="startTime()"

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.