• Subtract a specified amount of time (in units) from date object.

    Example

    subtractTime(new Date(2020, 3, 10), 5, TimeUnit.HOURS)  // "2020-04-10T02:00:00.000Z"
    subtractTime(new Date(2020, 3, 10), 3, TimeUnit.DAYS) // "2020-04-07T07:00:00.000Z"
    subtractTime(new Date(2020, 3, 10), 1, TimeUnit.MONTHS) // "2020-03-10T07:00:00.000Z"

    Returns

    JavaScript date object after subtracting the specified amount of time

    Parameters

    • date: Date

      JavaScript date object

    • amount: number

      Number of time units to subtract

    • unit: TimeUnit

      String token representing time unit

    Returns Date

Generated using TypeDoc