I have one object
objTime = {
"scheduleStartDate": "2022-07-13T12:00:00.540+00:00",
"slotDuration":30,
"noOfSlots":5,
}
I have to add scheduleEndDate dynamically by using slotDuraion key and noOfSlots is my loop length.
for (let i = 0; i < objTime.noOfSlots; i++) {
let startDateTime = moment(objTime.scheduleStartDate);
let expectedEndDateTime = moment(startDateTime).add(objTime.slotDuration, "minutes");
console.log(
`Start : ${moment(startDateTime).format("DD-MM-YYYY hh:mm:ss")} | End : ${moment(expectedEndDateTime).format("DD-MM-YYYY hh:mm:ss")}`
);
}
But it not works as accept I want o/p like this.
Start : 13-07-2022 05:30:00 | End : 13-07-2022 06:00:00
Start : 13-07-2022 06:00:00 | End : 13-07-2022 06:30:00
Start : 13-07-2022 06:30:00 | End : 13-07-2022 07:00:00
Start : 13-07-2022 07:00:00 | End : 13-07-2022 07:30:00
Start : 13-07-2022 07:30:00 | End : 13-07-2022 08:00:00
Any moment.js function for same I am using NodeJS. Thanks in advance.