Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check if string is valid date

const isDate = (str) => {
  return (new Date(str) !== "Invalid Date") && !isNaN(new Date(str));
}

console.log(isDate('2020-01-01'))
console.log(isDate('abc'))
Source by thewebdev.info #
 
PREVIOUS NEXT
Tagged: #check #string #valid #date
ADD COMMENT
Topic
Name
2+2 =