Answers for "hwo to ensure if string is of type date"

0

typescript how to check if string is a date

var isDate = function(date) {
    return (new Date(date) !== "Invalid Date") && !isNaN(new Date(date));
}
Posted by: Guest on May-31-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 "hwo to ensure if string is of type date"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language