-
-
Notifications
You must be signed in to change notification settings - Fork 0
date
Nicholas Berlette edited this page Jun 19, 2025
·
1 revision
function isDate(it: unknown): it is Date;
Checks if a given value is a Date
instance. This is a more reliable check than
it instanceof Date
because it also works across different realms.
This only returns true
for values that are valid Date
instances, meaning
Object.create(Date.prototype)
and similar constructs will return false
.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a Date
instance, false
otherwise.
Standard
import { isDate } from "jsr:@nick/is/date";
isDate(new Date()); // true
isDate(new Date(0)); // true
isDate(new Date("2021-01-01")); // true