- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
This is a fairly simple problem and we can achieve this with a few lines of code. At first, get today’s date −
// getting today's date const today = new Date();
Let’s write the code for this function −
// getting today's date const today = new Date(); // initializing tomorrow with today's date const tomorrow = new Date(today); // increasing a day in tomorrow and setting it to tomorrow tomorrow.setDate(tomorrow.getDate() + 1); const dayAfterTomorrow = new Date(today); dayAfterTomorrow.setDate(dayAfterTomorrow.getDate() + 2); console.log(today); console.log(tomorrow); console.log(dayAfterTomorrow);
Following is the output in the console −
2020-08-13T17:13:26.401Z 2020-08-14T17:13:26.401Z 2020-08-15T17:13:26.401Z
- Find yesterday’s, today’s and tomorrow’s date in Python
- Print dates of today, yesterday and tomorrow using Numpy
- Display record with today and tomorrow’s date from a column with date record in MySQL
- Format MySQL date and convert to year-month-day
- C++ Program to print current Day, Date and Time
- Compare only day and month with date field in MySQL?
- How to use date command in day to day practical usage
- How to display first day and last day of the month from date records in MySQL?
- Grab where current date and the day before with MySQL?
- Fetch date records comparing with the current date’s day and month in MySQL
- How to get day of month, day of year and day of week in android using offset date time API class?