With reference to these two questions:
I need to compare the dates and I need to distinguish three dates between two dates, either being equal or bigger or smaller / p>
function gerarData(str) {
var partes = str.split("/");
return new Date(partes[2], partes[1] - 1, partes[0]);
}
function teste(){
var data_1 = '03/03/2016';
var data_2 = '03/03/2016';
console.log( gerarData(data_1) );
console.log( gerarData(data_2) );
if ( gerarData(data_1) === gerarData(data_2) ) {
alert("Datas iguais com ===");
}
else if ( gerarData(data_1) == gerarData(data_2) ) {
alert("Datas iguais com ==");
}
else if ( gerarData(data_1) > gerarData(data_2) ){
alert("data_1 > data_2");
}
else if ( gerarData(data_1) < gerarData(data_2) ) {
alert("data_1 < data_2");
}
else{
alert("inconclusivo \n data_1="+gerarData(data_1)+" \n data_2="+gerarData(data_2));
}
}
teste();
Why even console.log
showing me that they are equal does not enter the condition that makes this check?