Hyperlinkv0.8.0-beta.28

DateTime

DateTime.toDateconsteffect/DateTime.ts:1582
(self: DateTime): Date

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())
converting
export const toDate: (self: DateTime) => Date = Internal.toDate