angular minus date

Solutions on MaxInterview for angular minus date by the best coders in the world

showing results for - "angular minus date"
Allan
06 Nov 2016
1const date = new Date();
2const oneWeekLater = addDaysToDate(date, 7); // also works with negative #s
3
4function addDaysToDate(date: Date, days: number): Date {
5    return new Date(date.getTime() + daysToMilliseconds(days));
6}
7
8function daysToMilliseconds(days: number): number {
9    // 24 hours, 60 minutes, 60 seconds, 1000 milliseconds
10    return days * 24 * 60 * 60 * 1000;
11}
12