I have a JSON object with these two fields...
"start_datetime": "3/9/2016 8:00",
"stop_datetime": "3/18/2016 16:00",
How can I tell if the current date/time is between these two?
16:00 - 4PM
08:00 - 8AM
DateTime objects can be compared with the standard comparison operators to tell if one is before the other.
var start = new Date(obj.start_datetime);
var end = new Date(obj.end_datetime);
var now = new Date();
if (now > start && now < end) {
// current date and time between start and end
} else {
// current date and time not between start and end
}
new Date("3/18/2016 16:00")Date.now() > new Date("3/9/2016 8:00") && Date.now() < new Date("3/18/2016 16:00"), have fun @softwareisfun