Hi I would like to check if given date is between 2 dates with hours of course. So if we check if 13:00 is between 13:00 and 15:00 I would like to get true.
I have this code:
let timeSlotStartTime = moment.utc(timeSlot.startTime);
let startDayTime = moment.utc(timeSlotStartTime.format('YYYY-MM-DD') + "T" + moment.utc(condition.parameters.timeFrom).format('HH:mm:00'));
let endDayTime = moment.utc(timeSlotStartTime.format('YYYY-MM-DD') + "T" + moment.utc(condition.parameters.timeTo).format('HH:mm:59'));
return timeSlotStartTime.isBetween(startDayTime, endDayTime);
So I am checking if it is between but it works weird.
If I set hours of startDayTime = 14:59 and endDayTime = 17:00 and timeSlotStartTime is 14:15 it stills gives me true.(this is the bigger problem)
and if timeSlotStartTime = 17:00 gives me false (which I want to give me true)
Is there any possibility I can check between and equal within 2 moments?
thanks
isBetween
that allows it to include the endsisBetween
is giving unexpected results then there is probably an issue with your datesisBetween
timeSlotStartTime.isBetween(startDayTime, endDayTime, 'minutes', '[]');