How to Calculate the First Day After 60 Days Using Acrobat JavaScript
Question details
The user needs to write a JavaScript snippet in Adobe Acrobat that takes a start date, adds 60 days, and automatically outputs the first day of the subsequent month.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating dynamic PDF forms where a specific future date needs to be automatically calculated and displayed based on user input.
- Observed behavior
- The goal is to accurately calculate a date that is 60 days from the start date, then shift that result to the 1st day of the next month using Acrobat JavaScript.
Ensure that your PDF form has a properly formatted source date field (e.g., named "StartDate" with the format "mm/dd/yyyy") before adding the custom calculation script to your target field.
Use Custom Calculation Script in Acrobat Form Fields
Apply a custom JavaScript code to the target text field's calculation event to process the date addition and month-shifting logic.
This script reads the date from a specified field and adds 60 days using the JavaScript setDate function. It then uses a conditional statement to check the calculated month. Because JavaScript months are zero-indexed (December is 11), if the month is December, the script advances the year by one and resets the month to January (0). Otherwise, it advances to the next month and sets the day to the 1st.
Open your PDF document in Adobe Acrobat, navigate to the 'Tools' menu, and select 'Prepare Form' to enter editing mode.
Right-click the text field where you want the final calculated date to appear and select 'Properties' from the context menu.
Go to the 'Calculate' tab, select 'Custom calculation script', and click the 'Edit' button. Paste the following code: var date = util.scand("mm/dd/yyyy", this.getField("StartDate").value); date.setDate(date.getDate() + 60); if (date.getMonth() == 11) { date.setFullYear(date.getFullYear() + 1); date.setMonth(0); } else { date.setMonth(date.getMonth() + 1); } date.setDate(1); event.value = util.printd("mm/dd/yyyy", date);
Click 'OK' to save the script, close the properties panel, and exit 'Prepare Form' mode. Test the calculation by entering a date into your 'StartDate' field.

Create and Edit Dynamic PDF Forms with WPS Office
WPS Office features a robust PDF editor that allows you to easily design interactive forms, insert text fields, and manage document properties. It is a lightweight, full-featured suite that handles PDFs alongside your standard Office document formats seamlessly.
- 1. Open your PDF in WPS Office: Launch WPS Office and open the PDF document containing the forms you want to edit.
- 2. Navigate to the Form Tools: Click on the 'Form' tab located on the top ribbon to reveal the interactive field options.
- 3. Insert and Modify Fields: Click 'Text Field' to insert new data entry points or double-click existing fields to open the properties dialog.
- 4. Configure Properties and Save: Adjust your field settings as needed, save the document, and distribute your interactive PDF.

Frequently Asked Questions
Why does my JavaScript date calculation return the wrong month?
In JavaScript, the getMonth() method is zero-indexed, meaning January is 0 and December is 11. If you manually set or check the month without accounting for this offset, your calculation will return an unexpected month. Always check if the month equals 11 before rolling over to the next year.
What is the purpose of util.scand in Acrobat?
The util.scand function is an Acrobat-specific JavaScript method used to convert a text string from a form field (such as "12/31/2023") into a valid JavaScript Date object so that mathematical operations like adding days can be performed on it.
Can I use a different date format like dd/mm/yyyy?
Yes, you can easily change the date format. Simply update the format string in both the util.scand and util.printd functions within the script to match your desired format (e.g., "dd/mm/yyyy"). Ensure the user input matches this format as well.
How do I troubleshoot if my calculated field remains blank?
First, verify that the input field name exactly matches the name referenced in this.getField("FieldName"). Check the Acrobat JavaScript console (Ctrl+J) for syntax errors, and ensure the input date actually follows the format expected by the util.scand function.




