Tempo API
    Preparing search index...

    Function format

    Formats a supported date-time value using a named format, template, or internationalization options. Scoped day/week time fields count wall-clock units from local midnight or Monday, independent of offset transitions. The roman modifier converts integers 1-3999 and leaves other values unchanged. {woy:cal} counts seven-day groups from the first day of the resolved date's calendar year, padded to two digits; {woy:cal:raw} removes padding.

    The value to format; omitted values use the current date and time.

    A registered format name or literal format template.

    Formatting and configuration overrides.

    The formatted date-time string, a format proxy when no format or options are supplied, or an empty string when a format is supplied and the resolved value is not a ZonedDateTime.

    Error when a requested dialect formatter is unavailable. Temporal input conversion errors, formatter or custom token callback errors, and Intl errors when no fallback succeeds also propagate.

    • Standalone Formatter Returns a formatted string from a Temporal.ZonedDateTime or Tempo instance.

      Parameters

      • Optionalobj: any

      Returns any

      import { format } from 'tempo-kit/format';
      const str = format(Temporal.Now.zonedDateTimeISO(), '{yyyy}-{mm}-{dd}');

      // Proxy usage (zero or one argument)
      const weekDate = format(zdt).weekDate;
      const stamp = format().logStamp; // defaults to 'Now'
    • Standalone Formatter Returns a formatted string from a Temporal.ZonedDateTime or Tempo instance.

      Parameters

      • obj: any
      • options: FormatOptions

      Returns string

      import { format } from 'tempo-kit/format';
      const str = format(Temporal.Now.zonedDateTimeISO(), '{yyyy}-{mm}-{dd}');

      // Proxy usage (zero or one argument)
      const weekDate = format(zdt).weekDate;
      const stamp = format().logStamp; // defaults to 'Now'
    • Standalone Formatter Returns a formatted string from a Temporal.ZonedDateTime or Tempo instance.

      Parameters

      • obj: any
      • fmt: string | symbol
      • Optionaloptions: any

      Returns string

      import { format } from 'tempo-kit/format';
      const str = format(Temporal.Now.zonedDateTimeISO(), '{yyyy}-{mm}-{dd}');

      // Proxy usage (zero or one argument)
      const weekDate = format(zdt).weekDate;
      const stamp = format().logStamp; // defaults to 'Now'