Function formatDate

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

    Example

    formatDate(new Date('2023-03-07T03:24:00'))
    // => { ok: true, value: '07/03/2023' }

    Example

    Handle invalid input:

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

    Parameters

    • date: Date

      The date to format.

    Returns Result<string, Error>

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

Generated using TypeDoc v0.24.7