effect-io-ai

Package: effect
Module: DateTime

DateTime.toDate

Converts 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())

Signature

declare const toDate: (self: DateTime) => Date

Source

Since v3.6.0