Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

angular minus date

const date = new Date();
const oneWeekLater = addDaysToDate(date, 7); // also works with negative #s

function addDaysToDate(date: Date, days: number): Date {
    return new Date(date.getTime() + daysToMilliseconds(days));
}

function daysToMilliseconds(days: number): number {
    // 24 hours, 60 minutes, 60 seconds, 1000 milliseconds
    return days * 24 * 60 * 60 * 1000;
}
Source by stackblitz.com #
 
PREVIOUS NEXT
Tagged: #angular #date
ADD COMMENT
Topic
Name
4+2 =