Hex Core JS
    Preparing search index...

    Function dateDiff

    • Calculates the difference between two date time objects, in a given unit. Note that this is an "anti-commutative" in the sense that reversing the arguments will negate the output. This is just like subtraction, i.e. end - start = -(start - end)

      Parameters

      • end: DateTime

        The later date time object.

      • start: DateTime

        The earlier date time object.

      • unit:
            | "y"
            | "d"
            | "h"
            | "m"
            | "s"
            | "w"
            | "M"
            | "year"
            | "month"
            | "day"
            | "hour"
            | "minute"
            | "second"
            | "week"
            | "years"
            | "months"
            | "weeks"
            | "days"
            | "hours"
            | "minutes"
            | "seconds"
            | "millisecond"
            | "milliseconds"
            | "date"
            | "dates"
            | "D"
            | "ms"
            | "quarter"
            | "quarters"
            | "Q" = "day"

        The units to calculate the difference in. Defaults to "day".

      • roundDown: boolean = true

        Whether or not to round down to an integer. Defaults to true.

      Returns number

      dateDiff(end, start) = -dateDiff(start, end);