1 Reply Latest reply on Apr 15, 2010 2:40 PM by try67

    comparing dates

    mmrm

      I have a form with two buttons and would like to check the time elapsed between the pushing of the first to the second.  I want to make sure that they are both pushed within like 4 hours.  I figure I'll probably need a hidden field to use as a date stamp for the first button.  I just don't know how to figure out if two times are within a certain range.

       

      Thanks!

        • 1. Re: comparing dates
          try67 MVP & Adobe Community Professional

          You can use a global Date variable. You set it when the first button is

          pushed, and then calculate how much time had passed when the second one is

          pushed.

          You can read about the JS's Date object here:

          http://w3schools.com/js/js_obj_date.asp

           

          First button is thus:

          global.startTime = new Date().getTime();

           

          Second button:

          totalTimeInMS = new Date().getTime() - global.startTime;

          totalTimeInHours = totalTimeInMS / 3600000;