var date=new Date() var year=date.getFullYear(); var day=date.getDate(); var month=date.getMonth(); var k=date.getTime(); var date1=new Date(year,month,day) var data2=new Date(year,month+1,day) console.log(date1,date2) console.log((date2.getTime()-date1.getTime())/(1000*60*60*24))