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 }