Ok!! I am trying to get date and month exactly 5 years ago from today's date in JQuery.
The main thing i am missing that i have to take care of leap years also and that i am struggling with.
I have tried below function
function printFiveYears()
{
var fiveYears = new Date();
fiveYears.setTime(fiveYears.valueOf() - 5 * 365 * 24 * 60 * 60 * 1000);
window.alert("5 years ago, the time and date were: " + fiveYears.toString());
}
But here, i am directly subtracting 365 days which is not right. Let me know corrections please.
Ps: No external plugins please.