Skip to content

Instantly share code, notes, and snippets.

@jouni-kantola
Created April 18, 2017 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jouni-kantola/f4e430a6c48c874da5b5c7f2f38bac55 to your computer and use it in GitHub Desktop.
Save jouni-kantola/f4e430a6c48c874da5b5c7f2f38bac55 to your computer and use it in GitHub Desktop.
Currently in date range
function isActive(startDate, endDate) {
var start = new Date(startDate);
var end = new Date(endDate);
var timeNow = new Date();
return (timeNow >= start.setHours(0, 0, 0, 0)) &&
(timeNow < end.setHours(0, 0, 0, 0));
}
// running on 2017-04-18
isActive("2017-04-01", "2017-04-18") // -> false
isActive("2017-04-01", "2017-04-19") // -> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment