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
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.