'Javascript moment Is within a date range api
Currently using http://momentjs.com/
Is there a function I can use as below to find out if array of dates fall within a single day?
Example:
Events0 - 21-12-2014 1130
Events1 - 24-12-2014 1030
Events2 - 24-12-2014 1130
Events3 - 24-12-2014 0800 until 26-12-2014
Events4 - 28-12-2014
I want momentjs to return me all events that is within 24-12-2014
So it should return
Event1
Event2
Event3
I tried below but not working well
var events = calendar.fullCalendar('clientEvents', function (event) {
if (event.start.isSame($scope.selectedDate)) {
return true;
} else {
return false;
};
});
Solution 1:[1]
Solved it using these conditions
var events = calendar.fullCalendar('clientEvents', function (event) {
if ((event.start <= $scope.selectedDate && event.end >= $scope.selectedDate) ||
event.start.isSame($scope.selectedDate, 'day')) {
return true;
} else {
return false;
}
});
I still prefer to use moment.js! Any idea if i can convert that to use moment library?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | ove |