get tomorrow's date in typescript

You can use the built-in Date object in JavaScript/TypeScript to get the current date and then add one day to it to get tomorrow's date. Alternatively, you can use the popular Moment.js library to simplify the process.

Using plain JavaScript/TypeScript:

index.ts
const today = new Date();
const tomorrow = new Date(today);
tomorrow.setDate(tomorrow.getDate() + 1);
console.log(tomorrow); // outputs the date object for tomorrow's date
172 chars
5 lines

Using Moment.js:

index.ts
import moment from 'moment';

const tomorrow = moment().add(1, 'day').toDate();
console.log(tomorrow); // outputs the date object for tomorrow's date
150 chars
5 lines

Both of these methods will give you the date object for tomorrow's date. You can then use the various methods available on the Date object to extract specific portions of the date, such as the day, month, or year, if required.

gistlibby LogSnag