effect-io-ai

Package: effect
Module: DateTime

DateTime.fromDateUnsafe

Create a DateTime from a Date.

Details

If the Date is invalid, an IllegalArgumentError will be thrown.

Example (Creating DateTime values from Dates)

import { DateTime } from "effect"

const date = new Date("2024-01-01T12:00:00Z")
const dateTime = DateTime.fromDateUnsafe(date)

console.log(DateTime.formatIso(dateTime)) // "2024-01-01T12:00:00.000Z"

Signature

declare const fromDateUnsafe: (date: Date) => Utc

Source

Since v4.0.0