Answers for "js check invalid date"

1

js check if date object is invalid

const isValid = !Number.isNaN(new Date(timestamp).getTime())
Posted by: Guest on September-21-2021
0

js check invalid date

const validDate = !isNaN(Date.parse('foo'))
Posted by: Guest on August-12-2021
0

new date javascript invalid date

if (Object.prototype.toString.call(d) === "[object Date]") {
  // it is a date
  if (isNaN(d.getTime())) {  // d.valueOf() could also work
    // date is not valid
  } else {
    // date is valid
  }
} else {
  // not a date
}
Posted by: Guest on May-26-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language