title: How to get difference between two dates in javascript when they are of different months
body: <p>I want to get the difference between two dates when they are in different months or years. I have used the code below</p>
  
  <p>var d1= lastexecdate.split(".");</p>
  
  <p>var d2= jabusinessdate.split(".");</p>
  
  <p>var date1= new Date(d1[2], d1[1],d1[0]);</p>
  
  <p>var date2= new Date(d2[2], d2[1],d2[0]);</p>
  
  <p>var timeDiff= (date2.getTime() - date1.getTime());</p>
  
  <p>var diffdays= Math.ceil(timeDiff/(1000*3600*24));</p>
  
  <p>When i use dates such as 17.10.2014 and 19.10.2014 it gives me a differenc of two which is perfect. But when i use dates such as 31.10.2014 and 1.11.2014 it gives me a result as zero where as the actual result should have been 1. That is when the months or year are different it shows anomaly in result. Please suggest me some ideas or some functions which i can use to get appropriate result.</p>