How to add a day to a date in TypeScript

I need to add 1 day to a date variable in TypeScript. Can I learn how to add a day to a date field in TypeScript.

+5
source share
2 answers

This is just plain JavaScript, TypeScript is not needed.

yourDate = new Date(yourDate.getTime() + (1000 * 60 * 60 * 24)); 

1000 milliseconds per second * 60 seconds per minute * 60 minutes per hour * 24 hours.

In addition, you can increase the date:

 yourDate.setDate(yourDate.getDate() + 1); 
+7
source
  addDays(date: Date, days: number): Date { date.setDate(date.getDate() + days); return date; } 

In your case days = 1

+2
source

Source: https://habr.com/ru/post/1264274/


All Articles