Function floor

  • Returns a new date representing the latest interval boundary date before or equal to date.

    For example, timeDay.floor(date) typically returns 12:00 AM local time on the given date.

    This method is idempotent: if the specified date is already floored to the current interval, a new date with an identical time is returned. Furthermore, the returned date is the minimum expressible value of the associated interval, such that interval.floor(interval.floor(date) - 1) returns the preceding interval boundary date.

    Note that the == and === operators do not compare by value with Date objects, and thus you cannot use them to tell whether the specified date has already been floored. Instead, coerce to a number and then compare.

    This is more reliable than testing whether the time is 12:00 AM, as in some time zones midnight may not exist due to daylight saving.

    Parameters

    • date: Date

      A date object.

    Returns Date