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]