Function diffDaysFromNow

  • Calculates the number of days passed from the given date string to the current date.

    Parameters

    • dateString: string

      The date string to calculate the difference from. The date string should be in a format recognized by the Date constructor.

    Returns number

    The number of days passed from the given date to today.

    Will throw an error if the date string is in an invalid format.

    const days = diffDaysFromNow('2023-01-01');
    console.log(days); // Outputs the number of days from January 1, 2023 to today