In this section, we are going to determine the difference between two dates.
getFullYear()-This method return the current year.
Math.ceil()- This method returns the rounded number to the nearest integer.
Following code calculate the difference between two dates in days:
Here is the code:
var today=new Date()
var date=new Date(today.getFullYear(), 2, 11)
document.write("Today's date is :"+today+"<br>");
document.write("Another date is :"+date+"<br>");
document.write("Difference between two dates is :"+
Output will be displayed as:
Recommend the tutorial