Here we will get the yesterday date, in this example we will show the output compare to today’s date.
var dateObj = new Date(); // empty Date constructor representing current time dateobj; // Current Time => Wed Jun 12 2019 20:52:24 GMT+0530 (India Standard Time)
The following programs illustrate the solution
// Returns Yesterday's date and time
Here we will get the yesterday date of pre-defined date which is Fri May 10 2019 16:30:00 GMT+0530 (India Standard Time).
var dateObj = new Date(2019, 04, 10, 16, 30, 00); // specified Date constructor representing particular time dateObj; // Specific Time => Fri May 10 2019 16:30:00 GMT+0530 (India Standard Time)
- Supported browser:
- Google Chrome
- Mozila Firefox
- Internet Explore