Formats a date or time according to the specified options.

  • Parameters

    • timestamp: string | number | Date

      The timestamp to format.

    • type: "time" | "date" | "datetime"

      The type of formatting to use. Can be 'date', 'time', or 'datetime'.

    • dateStyle:
          | undefined
          | "long"
          | "short"
          | "medium"
          | "full" = 'medium'

      The date formatting style to use. Defaults to 'medium'.

    • timeStyle:
          | undefined
          | "long"
          | "short"
          | "medium"
          | "full" = 'short'

      The time formatting style to use. Defaults to 'short'.

    • locale: string = 'en-US'

      The locale to use for formatting. Defaults to 'en'.

    Returns string

    The formatted date or time string.