JavaScript compares the data size of two time formats

Source: Internet
Author: User

Heheh, what do you do if you need to compare the two time points during software development? Well, the intuitive way is to remove "-" and then compare the size, is it really necessary? Let's take a look at the simplest time comparison method below:

<! 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">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> JavaScript compares the data size of two time formats. </title>
<Script type = "text/javascript" src = "./jquery-1.8.3.min.js"> </script>
<Script type = "text/javascript">
Function checkDate (){
If ($ ("# startDate"). val ()> $ ("# endDate"). val ()){
Alert ("the end time must be greater than or equal to the start time! ");
}
}
</Script>
</Head>
<Body>
Start Time: <input id = "startDate" value = "2013-12-31"/> <br>
End Time: <input id = "endDate" value = "2013-01-01"/> <br>
<Input type = "button" onclick = "checkDate ();" value = "Start comparison"/>
</Body>

</Html>

Download resources at 0 Points]

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.