How to get Tomorrow's Date in JavaScript

Updated onbyAlan Morel
How to get Tomorrow's Date in JavaScript

Eventually, you will come across a situation where you'll need to get tomorrow's date.

Maybe you're working with databases or a calendar, and you need to know what the next day is.

Whatever the reason, in this post, we'll learn how to get tomorrow's date in JavaScript.

Getting Tomorrow's Date

Everything related to dates and times in JavaScript is based on the Date object.

The Date object is the native JavaScript representation of a date and time, which we are going to use to get tomorrow's date.

First, let's start off with the basics. Let's get the current date and time.

const now = new Date();

From here, we're going to take advantage of the Date object's getDate() method, which returns the day of the month.

const now = new Date();

const today = now.getDate();

Now that we have today, we can just add one to it to get tomorrow's date. We will need to also use the setDate() method to set our new date.

const now = new Date();

const today = now.getDate();

const tomorrow = new Date(now);

tomorrow.setDate(today + 1);

Just like that, tomorrow is a new Date object with tomorrow's date. This is essentially the same as adding 24 hours to the time of now. In other words, the time of day did not change, simply the day itself.

If you want the very beginning of tomorrow, you can use the setHours() method to set it all to 0.

const now = new Date();

const today = now.getDate();

const tomorrow = new Date(now);

tomorrow.setDate(today + 1);
tomorrow.setHours(0, 0, 0, 0);

Now we have a new Date object with tomorrow's date at the very beginning of the day.

Conclusion

In this post, we took a look at how to get tomorrow's date in JavaScript. We learned how to get the current date and time, then add 24 hours to the time of day.

We even learned how to set it to the very beginning of tomorrow's day.

Hopefully, you've found this useful. Happy coding!

To learn more about web development, founding a start-up, and bootstrapping a SaaS, follow me on X!
Copyright © 2017 - 2024 Sabe.io. All rights reserved. Made with ❤ in NY.