How to Add 30 Minutes to a Time Field in a PDF Form
Question details
The user needs to automatically calculate and populate a time field that is exactly 30 minutes after a specified stop time within a PDF form.

- Product
- Adobe Acrobat / PDF Forms
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form that requires automatic time calculation, such as logging a discharge time based on an inputted stop time.
- Observed behavior
- The user wants a form field (DISCHARGE) to calculate a time automatically using a script based on another field (STOP).
Ensure you are using a PDF editor that supports custom JavaScript form calculations, such as Adobe Acrobat Pro, and verify that the target text fields are correctly named and set to identical time formatting.
Use a Custom JavaScript Calculation in Acrobat
Apply a custom JavaScript snippet to your target field to parse the inputted time, add 30 minutes, and display the formatted result.
Working with dates and times in Acrobat requires custom JavaScript because basic math functions only process standard numbers. You must extract the source field string, parse it into a JavaScript Date object, manipulate the minutes, and format it back to a readable time.
Open your PDF form in Adobe Acrobat, enter 'Prepare Form' mode, right-click the target field (e.g., 'DISCHARGE'), and select 'Properties'.
Navigate to the 'Calculate' tab in the Properties window and select the 'Custom calculation script' radio button.
Click the 'Edit' button and input a script that retrieves the 'STOP' field value. Use the script to convert this value into a Date object, add 30 minutes using the 'setMinutes(getMinutes() + 30)' method, and format the output as 'h:MM tt' using 'util.printd'.
Click 'OK' to save the script, close the Properties window, exit 'Prepare Form' mode, and enter a valid time into your 'STOP' field to verify that the 'DISCHARGE' time updates correctly.

Fill and Manage Interactive PDF Forms Easily with WPS Office
While creating custom JavaScript form logic requires specialized authoring tools, WPS Office provides a powerful, user-friendly PDF editor perfect for filling out interactive forms, modifying text, and managing your PDF documents quickly.
- 1. Open Your PDF: Launch WPS Office and click 'Open' to load your interactive PDF form.
- 2. Fill the Form Fields: Navigate through the document and click directly into the text fields to input your data, such as your Stop and Discharge times.
- 3. Add Signatures if Needed: Switch to the 'Fill & Sign' tab if you need to append a digital or handwritten signature to the finalized form.
- 4. Save and Export: Click 'Save' or use the 'Export to PDF' function to securely save your entered data and share the completed form.

Frequently Asked Questions
Why isn't my PDF time calculation script working?
This usually occurs if the input field's format does not match what the script expects. Ensure both the source and target fields have matching time formats (e.g., 'h:MM tt') and that the script correctly parses the input string into a Date object.
Can I use standard math calculations instead of JavaScript for time?
No. Standard math calculations in PDF forms are designed for regular numerical values. Time requires parsing hours and minutes within a 60-base system, which can only be achieved using custom JavaScript.
How do I format a date object to display as time in Acrobat JavaScript?
You can use Acrobat's built-in 'util.printd(format, dateObject)' method. For example, 'util.printd("h:MM tt", myDate)' will format a standard JavaScript Date object into a readable 12-hour time string with AM/PM.
Does WPS Office support filling out JavaScript-enabled PDF forms?
Yes, WPS Office supports viewing and filling out standard interactive PDF forms. However, authoring new forms with complex JavaScript calculations for date and time manipulation generally requires advanced PDF creation software.




