📌  相关文章
📜  角减日期 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:30.488000             🧑  作者: Mango

代码示例1
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;
}