Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Is Valid Date ?

const isDateValid = (...val) => !Number.isNaN(new Date(...val).valueOf());

isDateValid("December 17, 1995 03:24:00");
// Result: true
Comment

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'))
Comment

check if the Date is valid

const isDateValid = (...val) => !Number.isNaN(new Date(...val).valueOf());

isDateValid('December 17, 1995 03:24:00'); // true
isDateValid('1995-12-17T03:24:00'); // true
isDateValid('1995-12-17 T03:24:00'); // false
isDateValid('Duck'); // false
isDateValid(1995, 11, 17); // true
isDateValid(1995, 11, 17, 'Duck'); // false
isDateValid({}); // false
Comment

PREVIOUS NEXT
Code Example
Javascript :: js date difference in seconds 
Javascript :: image url to file js 
Javascript :: angular module with routing cli 
Javascript :: es6 foreach 
Javascript :: bottom shadow in react native 
Javascript :: graphql disable cache 
Javascript :: checking if a character is an alphabet in js 
Javascript :: check if 2 arrays are equal javascript 
Javascript :: how to do a classname variable and string react 
Javascript :: node colors log 
Javascript :: replace non alphanumeric javascript 
Javascript :: create folder by commend line 
Javascript :: like in javascript 
Javascript :: max_safe_integer 
Javascript :: bootstrap dropdown not working in angular 8 
Javascript :: fetch url in javascript 
Javascript :: onchange text input react native 
Javascript :: strart a nextjs project 
Javascript :: vuejs watch sub property 
Javascript :: jquery ajax type json 
Javascript :: google script get date without time 
Javascript :: javascript make obj invisible 
Javascript :: angular serve on different port 
Javascript :: get platform node 
Javascript :: how to connect metamask wallet with js 
Javascript :: javascript object syntax example with find 
Javascript :: angular MatDialogRef spec 
Javascript :: javascript fetch post form data 
Javascript :: how to get data from another website in javascript 
Javascript :: jquery get relative position of element 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =