Function formatDateISO

  • Formats a Date object into a string representation of the date in the ISO 8601 format "yyyy-mm-dd".

    Example

    formatDateISO(new Date())
    // => { ok: true, value: '2023-04-25' }

    Example

    Handle invalid input:

    formatDateISO(10)
    // => { ok: false, error: Error('[dates.formatDateISO] Expected string value as input') }

    Parameters

    • date: Date

      The Date object to format.

    Returns Result<string, Error>

    A Result object with a string containing the formatted date in the ISO 8601 format "yyyy-mm-dd" on success, or an Error object if the provided input is not a valid Date object.

Generated using TypeDoc v0.24.7