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 month1 = new Date(today.getTime() + (-720 * 60 * 60 * 1000));
var month2 = new Date(today.getTime() + (720 * 60 * 60 * 1000));
lastmonth = month1;
nextmonth = month2;
var a = lastmonth.getMonth();
var b = nextmonth.getMonth();
switch (a) {
case 0:
txt1 = "Jan";
break;
case 1:
txt1 = "Feb";
break;
case 2:
txt1 = "Mar";
break;
case 3:
txt1 = "Apr";
break;
case 4:
txt1 = "May";
break;
case 5:
txt1 = "June";
break;
case 6:
txt1 = "July";
break;
case 7:
txt1 = "Aug";
break;
case 8:
txt1 = "Sept";
break;
case 9:
txt1 = "Oct";
break;
case 10:
txt1 = "Nov";
break;
case 11:
txt1 = "Dec";
break;
}
alert("last month was " + txt1);
switch (b) {
case 0:
txt1 = "Jan";
break;
case 1:
txt1 = "Feb";
break;
case 2:
txt1 = "Mar";
break;
case 3:
txt1 = "Apr";
break;
case 4:
txt1 = "May";
break;
case 5:
txt1 = "June";
break;
case 6:
txt1 = "July";
break;
case 7:
txt1 = "Aug";
break;
case 8:
txt1 = "Sept";
break;
case 9:
txt1 = "Oct";
break;
case 10:
txt1 = "Nov";
break;
case 11:
txt1 = "Dec";
break;
}
alert("next month is " + txt1);
}
</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