
hi, I was actually working on to calculate the number of days between two dates of yyyy-mm-dd format using javascript, and when i click on button then number of days should be display in textbox.

Here is a javascript code that finds the number of days between two dates.
<html>
<head>
<script type="text/javascript">
function findDiff(){
var dob1= document.getElementById("dob1").value;
var dob2= document.getElementById("dob2").value;
var date1 = new Date(dob1);
var date2=new Date(dob2);
var ONE_DAY = 1000 * 60 * 60 * 24
var d1 = date1.getTime()
var d2 = date2.getTime()
var diff = Math.abs(d1 - d2)
document.getElementById("days").value=Math.round(diff/ONE_DAY);
}
</script>
</head>
<body>
<pre>
Enter Date1(yyyy-mm-dd): <input type="text" name="dob1" id="dob1" />
Enter Date2(yyyy-mm-dd): <input type="text" name="dob2" id="dob2" />
Number of days: <input type="text" name="days" id="days" />
<input type="submit" value="calculate" onclick="findDiff();">
</pre>
</body>
</html>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.