(
options?:
| (Intl.DateTimeFormatOptions & {
readonly locale?: string | undefined
})
| undefined
): (self: DateTime) => string
(
self: DateTime,
options?:
| (Intl.DateTimeFormatOptions & {
readonly locale?: string | undefined
})
| undefined
): stringFormats a DateTime with Intl.DateTimeFormat using the UTC time zone.
Details
This forces the time zone to be UTC.
Example (Formatting DateTime values in UTC)
import { DateTime } from "effect"
const dt = DateTime.makeZonedUnsafe("2024-06-15T14:30:00Z", {
timeZone: "Europe/London"
})
// Force UTC formatting regardless of time zone
const utcFormatted = DateTime.formatUtc(dt, {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
timeZoneName: "short"
})
console.log(utcFormatted) // "06/15/2024, 02:30 PM UTC"export const const formatUtc: {
(
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 UTC time zone.
Details
This forces the time zone to be UTC.
Example (Formatting DateTime values in UTC)
import { DateTime } from "effect"
const dt = DateTime.makeZonedUnsafe("2024-06-15T14:30:00Z", {
timeZone: "Europe/London"
})
// Force UTC formatting regardless of time zone
const utcFormatted = DateTime.formatUtc(dt, {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
timeZoneName: "short"
})
console.log(utcFormatted) // "06/15/2024, 02:30 PM UTC"
formatUtc: {
(
options: | (Intl.DateTimeFormatOptions & {
readonly locale?: string | undefined
})
| undefined
options?:
| Intl.interface Intl.DateTimeFormatOptionsDateTimeFormatOptions & {
readonly locale?: string | undefinedlocale?: string | undefined
}
| undefined
): (self: DateTimeself: type DateTime = Utc | ZonedA DateTime represents a point in time. It can optionally have a time zone
associated with it.
Companion namespace containing the public helper types used by DateTime
constructors, parts APIs, formatting, and date/time arithmetic.
DateTime) => string
(
self: DateTimeself: type DateTime = Utc | ZonedA DateTime represents a point in time. It can optionally have a time zone
associated with it.
Companion namespace containing the public helper types used by DateTime
constructors, parts APIs, formatting, and date/time arithmetic.
DateTime,
options: | (Intl.DateTimeFormatOptions & {
readonly locale?: string | undefined
})
| undefined
options?:
| Intl.interface Intl.DateTimeFormatOptionsDateTimeFormatOptions & {
readonly locale?: string | undefinedlocale?: string | undefined
}
| undefined
): string
} = import InternalInternal.const formatUtc: {
(
options?:
| (Intl.DateTimeFormatOptions & {
readonly locale?: Intl.LocalesArgument
})
| undefined
): (self: DateTime.DateTime) => string
(
self: DateTime.DateTime,
options?:
| (Intl.DateTimeFormatOptions & {
readonly locale?: Intl.LocalesArgument
})
| undefined
): string
}
formatUtc