Welcome aboard! We are happy you are here and wish you good net-raft!
<!DOCTYPE html>
<html>
<head>
<script>
function test() {
var today = new Date();
var year1 = new Date(today.getTime() + (-8760 * 60 * 60 * 1000));
var year2 = new Date(today.getTime() + (8760 * 60 * 60 * 1000));
lastyear1 = year1;
nextyear2 = year2;
var a = lastyear1.getFullYear();
var b = nextyear2.getFullYear();
alert("last year was " + a);
alert("next year is " + b);
}
</script>
</head>
<body>
<button onclick="test()">click</button>
</body>
</html>
The most helpful JAVASCRIPT solutions
How can I get the last day and the next day in javascript ?JAVASCRIPT Click to see more ... 5.8K 507