HTML & JavaScript

How to find difference between two dates in JavaScript?
var fromDate = new Date(document.getElementById('date1').value);
(or)
var d = new Date("15/02/2011");
alert(d.getTime());
alert(Date.parse(d));
var toDate = new Date(document.getElementById('date2').value);
var daysDifference = Math.ceil((toDate.getTime() - fromDate.getTime()) / (1000 * 60 * 60 * 24));



JSFIDDLE for javascript, html, css testing

No comments:

Post a Comment