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 yesterday = new Date(today.getTime() + (-24 * 60 * 60 * 1000));
var tomorrow = new Date(today.getTime() + (24 * 60 * 60 * 1000));
past = yesterday;
future = tomorrow;
var a = past.getDay();
var b = future.getDay();
switch (a) {
case 0:
day = "Sunday";
break;
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
case 6:
day = "Saturday";
}
alert("yesterday was " + day);
switch (b) {
case 0:
day = "Sunday";
break;
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
case 6:
day = "Saturday";
}
alert("tomorrow is " + day);
}
</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.9K 508