2 Replies Latest reply on Mar 26, 2017 9:49 PM by rebeccal10052843

    Working with time fields


      Sorry, I am a beginner but cannot find the exact answer in the previous questions.

      I have an adobe form with a text field (formatted to time HH:MM) in which the user enters a time in the format HH:MM. There is another text field, this one returns a numerical calculated value (which varies dependent on other inputs). I need the form to be able to add the value of the second field to the inputted time and return the answer in a third text field as a time in HH:MM. Please help

        • 1. Re: Working with time fields
          try67 MVP & Adobe Community Professional

          This code should do the trick:


          event.value = "";
          var startTime = this.getField("StartTime").valueAsString;
          if (startTime!="") {
              var d = util.scand("mm/dd/yyyy HH:MM", "01/01/2017 " + startTime);
              var v = this.getField("AddTime").valueAsString;
              if (v!="") {
                  var addTimeHours = Number(v);
                  var msPerHour = 3600000;
                  d.setTime(d.getTime() + (addTimeHours * msPerHour));
                  event.value = util.printd("HH:MM", d);
          1 person found this helpful
          • 2. Re: Working with time fields
            rebeccal10052843 Level 1

            Thanks try67 that seems to work just fine