js check if date is before today code example

Example 1: js check if date is today

const isToday = (someDate) => {
  const today = new Date()
  return someDate.getDate() == today.getDate() &&
    someDate.getMonth() == today.getMonth() &&
    someDate.getFullYear() == today.getFullYear()
}

Example 2: javascript date between two dates

// `min`, `max` and `date` are `Date` instances
const isBetween = (date, min, max) => (date.getTime() >= min.getTime() && date.getTime() <= max.getTime());

Example 3: how check if a form date is before today javascript

var Startdate = new Date(document.getElementById("Insert ID here").value)
var now = new Date();
if (before < now) {
  // selected date is in the past
}

Tags:

Sql Example