Input the year:
Input the month (zero based with 0 for January):
Input the day of the month:
Input the year:
Input the month (zero based with 0 for January):
Input the day of the month:
// sample-6-diference.js // display the difference between two dates // display the input date in several formats function display() { // First number - A var inputA1 = document.getElementById("inputA1"); var inputA2 = document.getElementById("inputA2"); var inputA3 = document.getElementById("inputA3"); // convert value strings to numbers var input_valueA1 = new Number(inputA1.value); var input_valueA2 = new Number(inputA2.value); var input_valueA3 = new Number(inputA3.value); // three numeric arguments passed to the Date constructor var dateA = new Date(input_valueA1,input_valueA2,input_valueA3); // Second number - B var inputB1 = document.getElementById("inputB1"); var inputB2 = document.getElementById("inputB2"); var inputB3 = document.getElementById("inputB3"); var output1 = document.getElementById("output1"); // convert value strings to numbers var input_valueB1 = new Number(inputB1.value); var input_valueB2 = new Number(inputB2.value); var input_valueB3 = new Number(inputB3.value); // three numeric arguments passed to the Date constructor var dateB = new Date(input_valueB1,input_valueB2,input_valueB3); // compute result output1.value = dateB.getTime() - dateA.getTime(); }