javascript question

Results 1 to 3 of 3

Thread: javascript question

  1. #1
    Join Date
    Dec 1969

    Default javascript question

    HI,<BR> How can I compare two date values in javascript? they are of the format dd/mm/yy. Any help is appreciated. Thanks...

  2. #2
    Join Date
    Dec 1969

    Default RE: javascript question

    compare it as a string

  3. #3
    Join Date
    Dec 1969

    Default Only works for == and !=

    Comparing dates as string when you want to do &#060; or &#060;= or &#062; or &#062;= will not work.<BR><BR>Consider:<BR><BR>1/1/2000 vs. 2/29/1900<BR><BR>the second date is *clearly* larger, as a string!<BR><BR>In JS code, you should convert the strings to Date objects and then compare the date objects. I *believe* that date objects properly compare! (I just checked: they certainly do with MS&#039s JavaScript.)<BR><BR>Thus:<BR><BR>d1 = new Date("11/11/2001")<BR>d2 = new Date("3/13/2000")<BR>if ( d1 &#062; d2 ) ...<BR><BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts