(self: DateTime): DateConverts a DateTime to a Date, applying the time zone first.
Details
For DateTime.Zoned, this adjusts for the time zone before converting.
For DateTime.Utc, this is equivalent to toDateUtc.
Example (Converting DateTime values to Dates)
import { DateTime } from "effect"
const utc = DateTime.makeUnsafe("2024-01-01T12:00:00Z")
const zoned = DateTime.makeZonedUnsafe("2024-01-01T12:00:00Z", {
timeZone: "Europe/London"
})
console.log(DateTime.toDate(utc).toISOString())
console.log(DateTime.toDate(zoned).toISOString())converting
Source effect/DateTime.ts:15821 lines
export const const toDate: (self: DateTime) => DateConverts a DateTime to a Date, applying the time zone first.
Details
For DateTime.Zoned, this adjusts for the time zone before converting.
For DateTime.Utc, this is equivalent to toDateUtc.
Example (Converting DateTime values to Dates)
import { DateTime } from "effect"
const utc = DateTime.makeUnsafe("2024-01-01T12:00:00Z")
const zoned = DateTime.makeZonedUnsafe("2024-01-01T12:00:00Z", {
timeZone: "Europe/London"
})
console.log(DateTime.toDate(utc).toISOString())
console.log(DateTime.toDate(zoned).toISOString())
toDate: (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) => Date = import InternalInternal.const toDate: (
self: DateTime.DateTime
) => Date
toDate