I would like to sort dates according to each id and when an id is passed it will appear in a "passed id" section, if it is in progress in a "current" section and if it is not in progress passed in a "coming soon" section. Start and end have this format: start: '2021-04-26T13:00:00.000Z', end: '2021-04-26T15:30:00.000Z'
Thank you !
here is my code :
fetch(urlCourses)
.then(res => res.json())
.then(function (data) {
let donnees = data;
//console.log( JSON.stringify(tabStudents));
donnees.forEach(e => {
tabCourses.push({
'id': e.id,
'name': e.name,
'start': e.start,
'end': e.end,
'school_id': e.school_id,
//'students': e.STUDENTS,
'classroom': e.classroom
});
});
tabCourses.sort(function (a, b) {
return new Date(a.start) - new Date(b.start);
});
console.log('tabCourses sorted', tabCourses);
})
.catch(function (error) {
console.log(error);
});