How to Calculate Elapsed Time Between Two Acrobat PDF Form Fields
Question details
The user needs to calculate the total elapsed time between a start-time and an end-time field within a PDF timesheet or form.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating a PDF tracking form that requires computing the exact difference between two time inputs, including scenarios that cross midnight or daylight-saving transitions.
- Observed behavior
- A standard calculation script must process the given date and time values, convert them to elapsed minutes or hours, and avoid resetting after 24 hours.
Ensure that both your start-time and end-time form fields are correctly configured to accept date and time inputs, and verify that you have access to the calculation properties of the PDF form fields.
Use a Custom JavaScript Calculation Script in Acrobat
Convert the date and time fields into JavaScript Date objects to calculate the precise difference in milliseconds before formatting it into hours and minutes.
Standard PDF form math functions cannot handle time calculations inherently. When dealing with timesheets that cross midnight or daylight saving time transitions, converting both the start and end inputs into JavaScript Date objects ensures total accuracy.
After calculating the elapsed time in milliseconds, you must divide by 60,000 to find the total minutes and format it appropriately for your final form field.
Right-click the result field where you want the elapsed time to appear, select Properties, and navigate to the Calculate tab.
Choose 'Custom calculation script' from the available options and click the Edit button to open the JavaScript editor.
Write JavaScript to retrieve the string values of your start and end fields, and instantiate them as Date objects (e.g., using new Date()). Ensure you include both the date and time to account for overnight shifts.
Subtract the start-time milliseconds from the end-time milliseconds. Convert the resulting value to minutes by dividing by 60,000, then apply custom logic to format and display the result as total hours and minutes.

Easily Track Time with WPS Spreadsheets
Instead of writing complex JavaScript for PDF forms, you can instantly calculate elapsed time using built-in formulas in WPS Spreadsheets. It offers an easier, highly reliable way to manage timesheets and exports perfectly to PDF when finished.
- 1. Launch WPS Spreadsheets: Open WPS Office and create a new blank spreadsheet or select one of the pre-made timesheet templates.
- 2. Input your time data: Designate two columns for Start Time and End Time (e.g., Column A and Column B), and enter your date/time values.
- 3. Apply a simple subtraction formula: In the result column, subtract the start time from the end time using a basic formula like =B2-A2.
- 4. Apply duration formatting: Right-click the result cell, choose Format Cells, and select a custom format like [h]:mm so the hours do not wrap around after 24 hours.

Frequently Asked Questions
Why does my PDF time calculation reset after 24 hours?
Standard time formatting in PDF forms operates on a 24-hour clock cycle. If your total elapsed time exceeds 23 hours and 59 minutes, it will wrap around back to zero. You must use JavaScript to format the output as a flat number of hours instead of a time of day.
Do I need to include the date when calculating time differences?
Yes. If your timesheet crosses midnight or occurs during a daylight saving time transition, the calculation will be mathematically incorrect unless both the date and the time are processed together within the JavaScript Date object.
How do I convert JavaScript milliseconds into minutes?
To convert the resulting milliseconds into minutes, divide the total millisecond difference by 60,000 (because there are 1,000 milliseconds in a second and 60 seconds in a minute).
Can I calculate elapsed time without JavaScript in Adobe Acrobat?
No, calculating the elapsed time between two form fields in Adobe Acrobat strictly requires custom calculation scripts. The built-in mathematical functions only support basic arithmetic like addition and multiplication.




