i have a date in this format from API 31-08-2021 13:58 I want to show this date in one mat-cell and then in another cell I have to add 7 to it eg: 7-09-2021 13:58 and display this how to achieve this.
Asked
Active
Viewed 533 times
-1
-
https://stackoverflow.com/questions/46368986/how-to-add-days-to-a-date-in-angular2 it might help – Mir entafaz Ali Aug 31 '21 at 15:11
-
Does this answer your question? [Add days to JavaScript Date](https://stackoverflow.com/questions/563406/add-days-to-javascript-date) – Heretic Monkey Aug 31 '21 at 15:28
1 Answers
0
You can do something like this in your ts file.
date = new Date();
nextDate = new Date();
ngOnInit() {
this.nextDate.setDate(this.date.getDate() + 7);
}
date - Current Date(can be your date from API response)
nextDate - date + 7 i.e next 7th day.

Aniket
- 110
- 1
- 12