Hyperlinkv0.8.0-beta.28

DateTime

DateTime.formatLocalconsteffect/DateTime.ts:2556
(
  options?:
    | (Intl.DateTimeFormatOptions & {
        readonly locale?: string | undefined
      })
    | undefined
): (self: DateTime) => string
(
  self: DateTime,
  options?:
    | (Intl.DateTimeFormatOptions & {
        readonly locale?: string | undefined
      })
    | undefined
): string

Formats a DateTime with Intl.DateTimeFormat using the system local time zone and locale.

Example (Formatting DateTime values locally)

import { DateTime } from "effect"

const dt = DateTime.makeUnsafe("2024-06-15T14:30:00Z")

// Uses system local time zone and locale
const local = DateTime.formatLocal(dt, {
  year: "numeric",
  month: "long",
  day: "numeric",
  hour: "2-digit",
  minute: "2-digit"
})

console.log(local) // Output depends on system locale/timezone
formatting
export const formatLocal: {
  (
    options?:
      | Intl.DateTimeFormatOptions & {
        readonly locale?: string | undefined
      }
      | undefined
  ): (self: DateTime) => string
  (
    self: DateTime,
    options?:
      | Intl.DateTimeFormatOptions & {
        readonly locale?: string | undefined
      }
      | undefined
  ): string
} = Internal.formatLocal