Hyperlinkv0.8.0-beta.28

DateTime

DateTime.formatIsoOffsetconsteffect/DateTime.ts:2772
(self: DateTime): string

Formats a DateTime.Zoned as an ISO string with an offset.

Details

For DateTime.Utc, returns the same as formatIso. For DateTime.Zoned, includes the time zone offset in the format.

Example (Formatting DateTime values with offsets)

import { DateTime } from "effect"

const utc = DateTime.makeUnsafe("2024-01-01T12:00:00Z")
console.log(DateTime.formatIsoOffset(utc)) // "2024-01-01T12:00:00.000Z"

const zoned = DateTime.makeZonedUnsafe("2024-01-01T12:00:00Z", {
  timeZone: DateTime.zoneMakeOffset(3 * 60 * 60 * 1000)
})
console.log(DateTime.formatIsoOffset(zoned)) // "2024-01-01T15:00:00.000+03:00"
formatting
export const formatIsoOffset: (self: DateTime) => string = Internal.formatIsoOffset