javascript函数

 1 function get_next_day(str_date){
 2         var d="";
 3         d=new Date(str_date);
 4         d.setDate(d.getDate()+1);
 5         var y=d.getFullYear();
 6         var m=d.getMonth()+1;
 7         var dd=d.getDate() < 10?‘0‘+parseInt(d.getDate()):parseInt(d.getDate());
 8         return y+"-"+m+"-"+dd;
 9 }
10 
11 
12 function count_days(date_in,date_out){
13         
14         var tmp_datein     = date_in.replace(/:/g,‘-‘);
15             tmp_datein     = tmp_datein.replace(/ /g,‘-‘);
16         var tmp_dateout = date_out.replace(/:/g,‘-‘);
17             tmp_dateout = tmp_dateout.replace(/ /g,‘-‘);
18         var date_time1    = tmp_datein.split(‘-‘);
19         var date_time2     = tmp_dateout.split(‘-‘);
20         
21         var timestamp1    = new Date(Date.UTC(date_time1[0],date_time1[1]-1,date_time1[2]));
22         var    unix_time1 = parseInt(timestamp1.getTime()/1000);
23         
24         var timestamp2    = new Date(Date.UTC(date_time2[0],date_time2[1]-1,date_time2[2]));
25         var    unix_time2 = parseInt(timestamp2.getTime()/1000);
26         
27         var nights_num = (unix_time2-unix_time1)/(24*3600);
28         
29         return nights_num;
30         
31 }
View Code

javascript函数,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。