Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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));
}
Comment

javascript check if string is valid date using Date constructor

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

console.log(isDate('2020-01-01'))
console.log(isDate('abc'))
Comment

javascript validate date

var date_regex = /^(0[1-9]|1[0-2])/(0[1-9]|1d|2d|3[01])/(19|20)d{2}$/;
if (!(date_regex.test(testDate))) {
    return false;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: Unable to resolve module react-navigation 
Javascript :: Fix the upstream dependency conflict, or retry npm ERR! this command with --force, or --legacy-peer-deps 
Javascript :: jquery disable class attribute 
Javascript :: javascript backticks and if statements 
Javascript :: javascript trello title swap 
Javascript :: go to page jquery 
Javascript :: js random 
Javascript :: js copy 2d array 
Javascript :: object to url params js 
Javascript :: localsstorage array append element 
Javascript :: jquery tag name 
Javascript :: js number remove last 2 characters 
Javascript :: ts-node dotenv 
Javascript :: select onchange jquery get the selected option data attribute 
Javascript :: uppercase string in js 
Javascript :: copy text to clipboard javascript 
Javascript :: arrow not showing react slick 
Javascript :: js for each element class 
Javascript :: token invalid discord bot 
Javascript :: get height and width of screen in react native 
Javascript :: javascript trim newline 
Javascript :: js math round up 
Javascript :: update node js ubuntu 
Javascript :: jquery datatable destroy and recreate 
Javascript :: javascript link to go back 
Javascript :: reduce average javascript 
Javascript :: js loop ul 
Javascript :: window.href 
Javascript :: enter event in jquery 
Javascript :: find intersection of multiple arrays in javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =