Answers for "check string is date or not in javascript"

2

check if a date time string is a valid date in js

const isValidDate = function(date) {
    return (new Date(date) !== "Invalid Date") && !isNaN(new Date(date));
}
Posted by: Guest on October-08-2021
0

how to check if a variable is of type Date in javascript

export const isDate = date => ((new Date(date) instanceof Date) && !isNaN(new Date(date)) && isNaN(date)) 
// here third check is added to check if user adds values like 1 , 2 etc
Posted by: Guest on December-14-2021

Code answers related to "check string is date or not in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language