Date comparison error with javascript -


i'm trying compare dates in javascript. why happend?

var strdate = "28/06/2014"; var arraydate = strdate.split("/"); var fechaturno = new date(arraydate[2], arraydate[1] - 1, arraydate[0]); var fechaactual = new date(); var fechalimite = new date(); fechalimite.setdate(fechaactual.getdate() + 10);  console.log(fechaturno); //  date {sat jun 28 2014 00:00:00 gmt-0300} console.log(fechaactual); //  date {fri jun 27 2014 08:36:24 gmt-0300} console.log(fechalimite); //  date {mon jul 07 2014 08:36:24 gmt-0300}  alert(fechaactual.getdate() <= fechaturno.getdate()); // true alert(fechaturno.getdate() <= fechalimite.getdate()); // false 

why last line false? should true. doing wrong?

in code don't see error

getdate return day of month

alert(fechaactual.getdate() <= fechaturno.getdate()); // true  because 27 < 28  alert(fechaturno.getdate() <= fechalimite.getdate()); // false because 28 > 7 

to compare whole date try just

alert(fechaactual <= fechaturno);  alert(fechaturno <= fechalimite); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -