Comparing dates in javascript

Results 1 to 2 of 2

Thread: Comparing dates in javascript

  1. #1
    Join Date
    Dec 1969

    Default Comparing dates in javascript

    I&#039;m trying to get a script to work that compares to dates and tells me whether one date is greater than another. I have used date.parse and date.UTC, but although they work fine in IE, Netscape does not allow either to work. Please help me!! Here&#039;s my code:<BR><BR> function checkDateOrder(dYear, dMont, dDay, rYear, rMonth, rDay)<BR> {<BR> if (Date.UTC(dYear, dMont, dDay) &#060;= Date.UTC(rYear, rMonth, rDay))<BR> {<BR> return true;<BR> }<BR> else<BR> {<BR> alert("The Return date must occur after the Departure date.");<BR> return false;<BR> }<BR> }

  2. #2
    Join Date
    Dec 1969

    Default Worked fine for me!

    On version 4.7x of Netscape.<BR><BR>Possibly you are making one of the following mistakes?<BR><BR>(a) You aren&#039;t passing integers. You are getting values from form fields and not invoking parseInt before passing them to the function. MSIE might be more tolerant of this error [i.e., it does the parseInt for you?] than NS?<BR><BR>(b) You are numbering your months 1..12 instead of 0..11, the latter being the JS spec. MSIE might be more tolerant of this error than NS? [Since December is 12 in the incorrect system, if you are using dates in the current month this would happen, wouldn&#039;t it?]<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