Hyperlinkv0.8.0-beta.28

DateTime

DateTime.toUtcconsteffect/DateTime.ts:918
(self: DateTime): Utc

Converts a DateTime to a UTC DateTime.

When to use

Use to represent the same instant in UTC instead of its current time zone.

Details

The returned value keeps the same epoch milliseconds and changes only the DateTime representation to UTC.

Example (Converting DateTime values to UTC)

import { DateTime } from "effect"

const now = DateTime.makeZonedUnsafe({ year: 2024 }, {
  timeZone: "Europe/London"
})

// set as UTC
const utc: DateTime.Utc = DateTime.toUtc(now)
time zones
export const toUtc: (self: DateTime) => Utc = Internal.toUtc
Referenced by 2 symbols