get the date 5 months from now in typescript

To get the date that is 5 months from now in TypeScript, you can use the Date object or a library like Moment.js.

Using the Date object, you can get the current date and add 5 months to it:

index.ts
const currentDate = new Date();
const futureDate = new Date(currentDate.setMonth(currentDate.getMonth() + 5));
111 chars
3 lines

Using Moment.js, you can use the add method to add 5 months to the current date:

index.ts
import * as moment from 'moment';

const currentDate = moment();
const futureDate = moment().add(5, 'months');
111 chars
5 lines

Both options will give you a Date object or Moment.js object that represents the date 5 months from now.

gistlibby LogSnag