Function offset

  • Returns a new date equal to date plus step intervals.

    If step is not specified it defaults to 1.

    This method does not round the specified date to the interval. For example, if date is today at 5:34 PM, then timeDay.offset(date, 1) returns 5:34 PM tomorrow (even if daylight saving changes!).

    Parameters

    • date: Date

      A date object.

    • Optional step: number

      An optional number of steps to apply when calculating the offset date. If step is negative, then the returned date will be before the specified date; if step is zero, then a copy of the specified date is returned; if step is not an integer, it is floored.

    Returns Date