JavaScript - test if variable is date type

3 points
Created by:

In this short article we would like to show ho to check if variable is date type.

Quick solution:

// ONLINE-RUNNER:browser;

function isDate(value) {
    return value instanceof Date;

// Usage example:

var value1 = '2020-07-02';
var value2 = new Date();
var value3 =;

console.log(isDate(value1)); // false
console.log(isDate(value2)); // true
console.log(isDate(value3)); // false

Note: read this article to know how to check variable type.

Native Advertising
50 000 ad impressions - 449$
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂