Answers for "angular minus date"

0

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;
}
Posted by: Guest on April-08-2021

Code answers related to "TypeScript"

Browse Popular Code Answers by Language