Hyperlinkv0.8.0-beta.28

DateTime

DateTime.formatIsoconsteffect/DateTime.ts:2693
(self: DateTime): string

Formats a DateTime as a UTC ISO string.

Details

Always returns the UTC representation in ISO 8601 format, ignoring any time zone.

Example (Formatting DateTime values as ISO strings)

import { DateTime } from "effect"

const dt = DateTime.makeUnsafe("2024-01-01T12:30:45.123Z")
console.log(DateTime.formatIso(dt)) // "2024-01-01T12:30:45.123Z"

const zoned = DateTime.makeZonedUnsafe("2024-01-01T12:30:45.123Z", {
  timeZone: "Europe/London"
})
console.log(DateTime.formatIso(zoned)) // "2024-01-01T12:30:45.123Z"
formatting
export const formatIso: (self: DateTime) => string = Internal.formatIso
Referenced by 1 symbols