How much code is js implemented from a certain time point?

Source: Internet
Author: User
Tags date1

Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml" xml: lang = "cn">
<Head>
<Title> positive timing </title>
<Meta http-equiv = "content-type" content = "text/html; charset = UTF-8"/>
<Style type = "text/css">
# ThenceThen {font-size: 2em ;}
</Style>
<Script type = "text/javascript" language = "javascript">
Function thenceThen (){
Var date1 = new Date (1381741113671 );
Var totalSecs = (new Date ()-data 1)/1000;
Var days = Math. floor (totalSecs/3600/24 );
Var hours = Math. floor (totalSecs-days * 24*3600)/3600 );
Var mins = Math. floor (totalSecs-days * 24*3600-hours * 3600)/60 );
Var secs = Math. floor (totalSecs-days * 24*3600-hours * 3600-mins * 60 ));
If (days! = 0 ){
Document. getElementById ("thenceThen "). innerText = "Answer time:" + days + "days" + hours + "hours" + mins + "Minutes" + secs + "seconds ";
} Else if (hours = 0 & mins = 0 ){
Document. getElementById ("thenceThen"). innerText = "Answer time:" + secs + "second ";
} Else if (hours = 0 & mins! = 0 ){
Document. getElementById ("thenceThen"). innerText = "Answer time:" + mins + "Minutes" + secs + "seconds ";
} Else if (hours! = 0 ){
Document. getElementById ("thenceThen"). innerText = "Answer time:" + hours + "Hour" + mins + "Minute" + secs + "second ";
}
}
Var clock;
Window. onload = function (){
Clock = self. setInterval ("thenceThen ()", 500 );
}
</Script>
</Head>
<Body>
<Div id = "thenceThen"> </div>
</Body>

</Html>

========================================================== ========================================================== ======================================

Var date1 = new Date (1381741113671 );

For parameter transfer, see the following section (you can also receive backend parameters ):

The following five parameters are supported:
Copy codeThe Code is as follows:
New Date ("month dd, yyyy hh: mm: ss ");
New Date ("month dd, yyyy ");
New Date (yyyy, mth, dd, hh, mm, ss );
New Date (yyyy, mth, dd );
New Date (MS );

Note the last form. The parameter represents the number of milliseconds between the creation time and the GMT time of January 1, January 1, 1970. The meanings of various functions are as follows:

Month: represents the name of a month in English, from January to December.

Mth: an integer representing the month, from (January 1, January) to 11 (January 1, December)

Dd: the day of a month, from 1 to 31.

Yyyy: The Year in four-digit format.

Hh: hours, from 0 (midnight) to 23)
Mm: The number of minutes, an integer from 0 to 59.

Ss: number of seconds, an integer from 0 to 59

Ms: Number of milliseconds, an integer greater than or equal to 0

For example:
Copy codeThe Code is as follows:
New Date ("January 12,2006 22:19:35 ");

New Date ("January 12,2006 ");

New Date );

New Date (2007,0, 12 );

New Date (1137075575000 );

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.