get the date 5 days from now in typescript

To get the date 5 days from now using typescript, you can use the popular Moment.js library. First, make sure to install Moment.js as a dependency by adding the following line to your project's package.json:

index.ts
npm install moment
19 chars
2 lines

Then, import Moment.js and use the 'add' function to add 5 days to the current date:

index.ts
import moment from 'moment';

const currentDate = moment(); // Get the current date
const futureDate = moment().add(5, 'days'); // Add 5 days to the current date

console.log(futureDate.format('MM/DD/YYYY')); // Output: a string in the format of "MM/DD/YYYY"
259 chars
7 lines

The 'format' function can be used to format the date string in any format you desire.

related categories

gistlibby LogSnag