Function dateDiff

  • Calculates the difference between two provided dates and returns the result in various formats.

    Parameters

    • from: Date

      The starting date.

    • to: Date

      The ending date.

    • showNegative: boolean = true

    Returns {
        days: number;
        full: string;
        hours: number;
        minutes: number;
        short: string;
    }

    • An object containing the short and full string representations of the difference, as well as the individual calculated values.
    • days: number
    • full: string
    • hours: number
    • minutes: number
    • short: string

    Example

    console.log(dateDiff(new Date("12/12/2012"), new Date()));
    // Output
    {
    "short": "3885d 15h 39m",
    "full": "3885 day(s) 15 hours, 39 minutes",
    "days": 3885,
    "hours": 15,
    "minutes": 39
    }

Generated using TypeDoc