
I want to find the difference between two dates with respect to years. I am using javascript. Please help.

<html>
<head>
<script type="text/javascript">
var date1=new Date();
var date2 =new Date("Jan, 11, 2000")
var yearDiff=date1.getFullYear()-date2.getFullYear();
document.write("Date difference in years : "+yearDiff);
</script>
</head>
</html>
Description: In javascript whenever you write new Date() it shows the current date in standard format with current day,date,time and GMT.you can also specify your own date by using new Date(). You can get number of years by using getFullYear() function.now you can get year difference by subtracting the two.
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.