Does anyone know what is wrong, that this script in this case, a bad number of days in the difference in dates? The difference should be 2 days - the script shows 1 day.
If the difference is in the same month is OK.

<script type="text/javascript">

var date_from = new Date(2012, 03, 31).getTime();

var date_to = new Date(2012, 04, 02).getTime();

document.write((date_to - date_from)/(1000*60*60*24));

</script>

ok problem solved!
Good code:

<script type="text/javascript">

      var mDate_od = new Date(2012, (03-1), 31).getTime();
      var mDate_do = new Date(2012, (04-1), 03).getTime();
	document.write(Math.abs(Math.round((mDate_do - mDate_od)/(1000*60*60*24))));

 </script>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.