Skip to content

isDate

Checks if a value is a Date instance.

Note: this only checks the type, not whether the Date is valid. Use date/isValid to also validate that the Date is not Invalid Date.

Available since v2.0.0

import { isDate } from '@helpers4/guard';
isDate(value: unknown): value is Date
ParameterTypeDescription
valueunknownThe value to check

value is Date — True if value is a Date instance

isDate(new Date())          // => true
isDate(new Date('invalid')) // => true (still a Date instance)
isDate('2023-01-01')       // => false
isDate(1609459200000)      // => false

View source on GitHub