get the current date, add 2 months, and 13 days to it in typescript

You can use the built-in Date object in TypeScript/JavaScript to accomplish this task. Here's the code:

index.ts
// Get current date
let currentDate = new Date();

// Add 2 months
currentDate.setMonth(currentDate.getMonth() + 2);

// Add 13 days
currentDate.setDate(currentDate.getDate() + 13);
182 chars
9 lines

This code first creates a new Date object with the current date. Then, it adds 2 months to the date using the setMonth() method. Finally, it adds 13 days to the date using the setDate() method.

The Date object automatically handles wrapping the month and year as needed. For example, if the current date is December 31 and you add 1 month, it will correctly wrap to the following year.

gistlibby LogSnag