3 Replies Latest reply on Aug 7, 2016 7:22 AM by ogallagher1

# Calculating Time and money in Adobe Acrobate Pro DC

Hello,

I have tried so many different ways to calculate the time in my PDF.  This form is for my employees to track their time throughout the pay period.

Partial of the form.

!

On day 1:  They will enter the day

Start time: Beginging of shift

End Time: End time of the shift

Type:  The staff will choose Program or Training (different pay rate)

Total Hours: Total time worked

Total\$:  Money they earned.

I need to have the total hours calculate their time and the total\$ to equal their pay for the day.

If you would like to see the actual PDF, I can send it via email

• ###### 1. Re: Calculating Time and money in Adobe Acrobate Pro DC

This issue was discussed many times on the forums. Calculating time differences using JS is not a simple task.

Here are a couple of good tutorials on the subject:

https://acrobatusers.com/tutorials/working-with-date-and-time-in-acrobat-javascript

https://acrobatusers.com/tutorials/working-with-date-and-time-in-acrobat-javascript-part-2

https://acrobatusers.com/tutorials/working-with-date-and-time-in-acrobat-javascript-part-3

If you already wrote some code and it's not working well, you can post it here, or upload the file to a file-sharing site and then post the link to it here.

If you're interested, I've also developed a tool that allows you to set up such calculations quite easily, without having to write any code. You can purchase it from here: Custom-made Adobe Scripts: Acrobat -- Calculate Time Differences in a Worksheet

• ###### 2. Re: Calculating Time and money in Adobe Acrobate Pro DC

The script is made up many statements. Firs one needs know how to get the value of the fields. For date and time calculations one needs to convert the date and time strings (these values are not numbers) to the JavaScript date and time object. The value of a date time object is a unique ascending number that represents a specific date and time. Form this value for the start and end values one can compute the elapsed time in any unit form milliseconds on up. The rest is just some arithmetic. Because of how JavaScript uses the system date, time and time zone offset the JavaScript will include any correction for DST or Summer time. It appears that your start and end times will occur all within the same day. If the do not, then the script becomes more complex.

• ###### 3. Re: Calculating Time and money in Adobe Acrobate Pro DC

You need to convert your time string to a DateTime object and then use the properties of this object to perform your calculations.

Are you trying to compute elapsed time between 2 events or trying to compute a future or past time?

Time for elapsed times can exceed 24 hours but the time within a day can not exceed 24 hours.

See Thom Parkers 3 part series about date and time calculations in the tutorials posted on this site.