JavaScript Date

Results 1 to 2 of 2

Thread: JavaScript Date

  1. #1
    Join Date
    Dec 1969

    Default JavaScript Date

    I have two dates<BR><BR>ie 26/2/2002 (dd/mm/yyyy) and 17/1/2002 (dd/mm/yyyy)<BR><BR>I need to make sure that the first date is lower than the second date. I am using a javascript function to validate this.<BR><BR>Unfortunatly JavaScript appears to read the first date as the 2nd February 2004 and the second date as 1st May 2003. I can see that it is reading the date in mm/dd/yyyy format. <BR><BR>I can&#039;t use that (mm/dd/yyyy) format as I am in England. Has anyone come across this issue and know of a solution?

  2. #2
    Join Date
    Dec 1969

    Default If you KNOW...

    ...that the dates are going to be put in in dd/mm/yyyy format, why not just swap the first two bits?!<BR><BR>That way, JavaScript will recognise them! :)<BR><BR>var myarray = "26/2/2002".split("/");<BR>var mynewstring = myarray[1] + "/" + myarray[0] + "/" + myarray[2];<BR><BR>Or something similar - I haven&#039;t got my JS book open at the moment.<BR><BR>Craig.

Posting Permissions

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