I have Schedule array with start/end date time and its layouts name.
let schedule=[
{
"start": "2017-10-01 08:00:00",
"end": "2017-10-01 09:00:00",
"layout": "layout1.json"
},
{
"start": "2017-10-01 10:00:00",
"end": "2017-10-01 12:00:00",
"layout": "layout2.json"
},
]
let current_time = "2017-10-01 10:30:00";
If current dateTime is **current_time**
in need to get layout name layout2.json
.
need to search between dateTime from above array using JavaScript.
I have try below code but its not working ..
for (i = 0; i < schedule.length; i++){
if (schedule[i].start >= current_time && schedule[i].end <= current_time){
return schedule[i].layout;
}
}
Help me, Thanks