1 Reply Latest reply on Nov 13, 2012 7:48 AM by gkaiseril

    Time Difference using Dropdowns - Image included

    ahlaj77 Level 1



      As pictured above, I have dropdowns that will display the hours, minutes and whether it is AM or PM. I have a client (mentioned the possibility of using dropdowns) who is wanting the total hours calculated (in decimal form.....time out - time in) after the user has filled out the dropdown boxes. Is this possible? I have never done time calculating before so it is all new to me. Help, suggestions, etc. would be very helpful! Would I need to format the dropdowns to format to hours and do the same for minutes? I am not sure where to start. Thanks!

        • 1. Re: Time Difference using Dropdowns - Image included
          gkaiseril MVP & Adobe Community Professional

          JavaScript accesses field values by field names or the event.


          Once you get you time values into one or more variables you can use the "util.scand" to convert the formatted string to the Date object and you can use any of a number of the methods of the date object to get a processable value. If you use the getTime method or  Number constrictor you can then perform Date arithmatic as needed using the milliseconds from the fixed Epoc date.


          You will need to provide a date in order to get the string to convert to the Date object.


          You could also just use the various fields and convert the hours to a 24 hour system, use the pm field to adjust the hours by 12. And then do the simple math and barrow from the hours if the minutes go negative.