check if date is between range javascript code example

Example 1: check if date is between range javascript

var a = new Date(2014, 0, 1);
var b = new Date(2014, 0, 2);

var c = new Date(b.getTime());   // clone the date to not muck the original value
c.setDate(c.getDate()+1);        // add a day
var inRange = dt >= a && dt < c; // use a half-open interval

Example 2: check if date is between range javascript

var a = new Date(2014, 0, 1);
var b = new Date(2014, 0, 2);
var inRange = dt >= a && dt <= b;

Tags:

Misc Example