Comparison of Dates in JScripts

Results 1 to 2 of 2

Thread: Comparison of Dates in JScripts

  1. #1
    Soma Guest

    Default Comparison of Dates in JScripts

    How to compare two dates in jscripts<BR><BR>

  2. #2
    Mehmet Guest

    Default RE: Comparison of Dates in JScripts

    I hope this helps. I don&#039;t know what kind of comparison you want but below code checks if two dates are the same or not. However, it gives you a starting point if you require more.<BR><BR>&#060;SCRIPT&#062;<BR>//set a date e.g. 01/01/2001<BR>var date1= "01 Jan 2001";<BR>alert ("First Day : " + date1);<BR><BR>//get another date<BR>var date2 = "01May 2001";<BR>alert ("Second Day : " + date2);<BR><BR>//return the time represented in miliseconds between the "date"<BR>//and "01/01/1970"<BR>date1= Date.parse(date1);<BR>date2= Date.parse(date2);<BR><BR>if (date1==date2)<BR> alert ("the dates are the same");<BR>else<BR> alert ("the dates aren&#039;t the same");<BR><BR>&#060;/SCRIPT&#062;

Posting Permissions

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