logo       

[jQuery] Re: inArray not working with dates: msg#02901

jQuery

Subject: [jQuery] Re: inArray not working with dates


Well, I guess this is intrinsic to javascript. I didn't know that
date compares were not reliable. Seems to work with milliseconds
though. Learn something new every day.

var dt1 = new Date(2009,7-1,31);
var dt2 = new Date(2009,7-1,31);
alert(dt1 === dt2); //false
alert(dt1 == dt2); //false
alert(dt1.getTime() === dt2.getTime()); //true

Dave


On Jul 31, 10:16 am, Fontzter <dmfo...@xxxxxxxxx> wrote:
> Can someone tell me what I may be doing wrong here?
>
>         var dateList = new Array();
>         dateList.push(new Date(2009,7-1,29));
>         dateList.push(new Date(2009,7-1,30));
>         dateList.push(new Date(2009,7-1,31));
>         var testdate = new Date(2009,7-1,30);
>         alert($.inArray(testdate,dateList)); //returns -1  ????
>
> tia,
>
> Dave

Google Custom Search

News | Mail Home | sitemap | FAQ | advertise