1 <html>
2 <head>
3 <title>
4 js
5 </title>
6 <Script language="JavaScript">
7
8
9 function datelimit(date1,date2,limit){
10
11 var a = date1.substr(5,2);
12 var b = date1.substr(8,2);
13 var c = date1.substr(0,4);
14 var a2 = date2.substr(5,2);
15 var b2 = date2.substr(8,2);
16 var c2 = date2.substr(0,4);
17 alert( date1+"__"+date2+"\n\n"+c+"__"+a+"__"+b+"\n\n"+c2+"__"+a2+"__"+b2);
18 if(c===c2){
19 if(a==a2&&b>=b2){
20 if(Number(b)-Number(b2)<=limit){
21 alert(Number(b)+"-"+Number(b2)+"="+(Number(b)-Number(b2)));
22 return true;
23 }
24 }else if(Number(a)-Number(a2)==1){
25 alert(Number(a)+"-"+Number(a2)+"="+(Number(a)-Number(a2)));
26 if(30+Number(b)-Number(b2)<=limit){
27 return true;
28 }
29 }
30 }else if(c-c2===1){
31 if((Number(a)==1)&&(Number(a2)==12)){
32 if(30+Number(b)-Number(b2)<=limit){
33 return true;
34 }
35 }
36 }else if(c2-c===1){
37 if((Number(a2)==1)&&(Number(a)==12)){
38 if(30+Number(b2)-Number(b)<=limit){
39 return true;
40 }
41 }
42 }
43 return false;
44 }
45
46 function alertTest(date1,date2,limit){
47 alert(datelimit (date1,date2,limit));
48 }
49 </Script>
50 </head>
51 <body>
52 <form name="ttt">
53 <input type="button" name="ddd" value="confirm" onclick="alertTest('2013-01-01 00:00:00','2012-12-31 23:59:59',3)">
54 </form>
55
56 </body>
57 </html>