Hello i am new to javascript , i tried a lot i cant get this format yyyy-mm-ddT00:00:00, i want to get this format in java script to compare it with other dates in an array and then get the next valid date that will come .
also if some one can show me a function on how to compare and get the closest greater date than today .
datesarray = ['2017-12-09T00:00:00' ,'2017-12-13T00:00:00' ,'2017-12-02T00:00:00' ,'2017-12-16T00:00:00']
let diffDate = Infinity;
let now = Date.now;
for (let i = 0; i < datesarray.length; i++) {
let closest = datesarray[0];
if (closest > now && closest < diffDate)
{
diffDate = closest;
}
}
this is what i tried but its never getting into the if statement . PS : i have other dates in an array but i did not show them here .