I have to compare two Dates in JS, representing the beginning of the next session. All Sessions are saved in a String array. If the actualSession is over,nextSession shall be the actual Session and the nextSession becomes the first element of the array, then it is shifted off. But the comparison of the Dates does not work. Can you help me?
function initializeComparison(){
getNextSession();
window.setInterval("getNextSession()", 15000);
}
function getNextSession(){
var actual_session = new Date(2017, 6, 22, 17,00);
var next_session = new Date(2017, 7, 6, 17, 00);
var allSessionsString = new Array("September 16, 2017 17:00:00", "September
30, 2017 17:00:00"); //more to come, just for example
if(actual_session < next_session){
actual_session = next_session;
next_session = new Date(allSessionsString[0]);
allSessionsString.shift();
}
var element = document.getElementById("nextSession");
element.innerHTML = "Next Session: " + actual_session.toLocaleString();
}