3 Replies Latest reply on Dec 15, 2013 12:03 PM by gkaiseril

# Military Time Equation

So here is the problem:

I have 3 fields which are entered by the user: arrival time, time cleared, and other. When all 3 fields are entered they are calculated and will give a total

(time cleared - arrival time + other) = total

Now in a perfect world the user would never have something like arrival time: 2345, time cleared: 0045, other: 30, with the calculation it will out put = -2270 but it should be 90

Any ideas for the calculation?

Thanks,

Nathan

• ###### 1. Re: Military Time Equation

Acrobat forms does not have the miltary time format, so you need to create a custom time format. You also need to be aware that the any time format in an Acrobat form is the time of day on a given day which starts and 0000, midnight, and ends at 2359:59.9999 or the millisecond before midnight of hte next day. Time values are character strings and not numberic floating point values so the string of numbers needs to be converted from a character string to a number for the number for the day hours and minutes and then converted to a comon unit for computations, like milliseocnds or hours. It you use the built-in time formats and JavaScript conversion mehtods then the date is also an important variable that needs to be accounted for.

Arrival time: 2345 the previous day

time cleared : 0045

other time: 30 minutes

The total elapsed time is:

60 minutes or the current date's 0045 time - the previous day's 2345.

and 30 minutes or 90 minutes.

You computation is:

(45 - 2345) + 30 =  -2270

When you want to compute in minutes:

((24 * 60) + 45) - ((23 * 60) + 45) + 30

or

1485 - 1425 + 30

With variables for the days and time:

var ArrivalDay = 0;
var ArrivalHour = 23;
var ArrivalMinute = 45;
var DepartureDay = 1;
var DepartureHour = 00;
var DepartureMinute = 45;
var Other = 30;

((DepartureDay * 24 * 60) + (DepartureHour * 60) + DepartureMinute) - ((ArrivalDay * 24 * 60) + (ArrivalHour * 60) + ArrivalMinute) + Other;

• ###### 2. Re: Military Time Equation

How did you come up with these numbers: 1485 - 1425 + 30, now I under stand they come from ((24 * 60) + 45) - ((23 * 60) + 45) + 30??

But where do they come from if the math is: (45 - 2345) + 30 =  -2270

• ###### 3. Re: Military Time Equation

Departure is the next day from the arrival date not the same day.