How to operate time in "draft" JS

Source: Internet
Author: User

    • How to declare a time variable
    • How to set time, minutes, seconds, and milliseconds for a temporal variable
    • How to declare a specified time variable based on a string variable
    • How to compare two time variables

The code is as follows:

1 $ (function () {2         varD =NewDate ();3D.sethours (0); D.setminutes (0); D.setseconds (0); D.setmilliseconds (0);4         5         varZhiding ="2015-08-10";6         if(zhiding.length===Ten){7zhiding+='00:00:00';8         }9         varD2 =NewDate (Zhiding.replace (/-/g,'/'));Ten         if(d-d2==0) Alert ('The current time is equal to the specified time'); One         Else if(d-d2>0) Alert ('The current time is greater than the specified time'); A         Else if(d-d2<0) Alert ('The current time is less than the specified time'); -})

The first three points, a look at the show, about how to compare two time variables, but ate a great hardship, the previous code is the use of this notation, but not the correct results:

1         if (d = = D2) alert (' current time equals specified time '); 2         Else if (d > D2) alert (' current time is greater than specified time '); 3         Else if (d < D2) alert (' current time is less than the specified time ');

How to operate time in "draft" JS

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.