Unfortunately, the moment().add() function is not functioning properly in my JavaScript code.
var theDate = moment(event.start.format("YYYY-MM-DD HH:mm")); //start Date of event
var checkquarter = theDate.add(30, 'minutes');
var plus = 30;
if (userDuration == '45') {
plus = 45;
}
for (var i = 0; i < excludedList.length; i++) {
var excludedTomorrow = moment(excludedList[i]["excludedDate"]).format("YYYY-MM-DD HH:mm"); //start Date of event that should be excluded
var endtime = moment(excludedTomorrow).add(plus, 'minutes'); //endTime of event that should be excluded
if (excludedList[i]["id"] == '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="34555555745359555d581a575b59">[email protected]</a>') {
console.log(endtime);
console.log(plus);
console.log(theDate);
console.log(checkquarter);
}
//var endtimeForCompare = moment(endtime);
if (theDate >= excludedTomorrow && theDate < endtime && Id == excludedList[i]["id"]) {
return false;
}
}
<script src='https://momentjs.com/downloads/moment.js'></script>
In this particular snippet of code, I have utilized the moment add function twice. Firstly, checkquarter adds 30 minutes to theDate variable. Secondly, endtime adds a specified number of minutes stored in the plus variable to excludedTomorrow, retrieved from the database.
The console output can be viewed in this image link. Upon inspection, you will notice that no changes are being made to the endtime, plus, theDate, and checkquarter variables as expected.
To incorporate momentJS into my script, I have included the following:
<script src='https://momentjs.com/downloads/moment.js'></script>