date difference in days



    John Jones

    The following code calculates the number of days between two dates. It uses the Ceil() function to round up the number of days to the nearest integer.

    const daysDiff = (date, date2) => Math.ceil(Math.abs(date – date2) / 86400000);
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.