PDF Editing Issues

How to Compare Dates in Adobe Acrobat JavaScript Forms

Jason MillerJason Miller Oct 28, 2026 868 views

Question details

The user needs to create an Adobe Acrobat JavaScript calculation to compare form input dates against a specific deadline, such as charging different fees before and after a set date.

How to Compare Dates in an Acrobat JavaScript Form
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Creating a dynamic PDF form with time-sensitive pricing or registration deadlines.
Observed behavior
The goal is to accurately parse and compare date values within an Acrobat PDF form using JavaScript to trigger dynamic field changes.
Before you start

Ensure your PDF form has the necessary text fields configured for date input, and verify that you have access to the 'Prepare Form' tools to insert custom calculation scripts.

Solution 1Recommended

Use the Standard JavaScript Date Constructor

Create a target deadline date object by passing the year, month, and day directly into the standard JavaScript Date method.

Standard JavaScript Date constructors use a zero-based index for months. This means January is represented by 0, February by 1, and March by 2. You must account for this offset when hardcoding your deadline date in the script.

1
Access Form Properties

Open your PDF in Adobe Acrobat, enter the 'Prepare Form' mode, right-click the calculation field (e.g., the fee total), and select 'Properties'.

2
Navigate to the Calculate Tab

Click on the 'Calculate' tab at the top of the Properties dialog box and select the 'Custom calculation script' option.

3
Define the Target Date

Click 'Edit' and enter the Date constructor variable. For example, to set March 16, 2019, type: var DeadlineDate = new Date(2019, 2, 16);

4
Implement Comparison Logic

Add your conditional if/else statements to compare the user's input date against DeadlineDate, and assign the appropriate fee output based on the result.

Use the Standard JavaScript Date Constructor
Zero-Based Month Reminder: Always subtract 1 from the actual month number when using new Date(year, month, day). Failing to do so will set your deadline to the wrong month.

Manage and Fill Interactive PDF Forms with WPS Office

If you are looking for a highly capable and user-friendly tool to handle PDF files, WPS Office provides a robust PDF editor. It easily opens, fills, and manages interactive PDF forms without requiring complex scripting.

  1. 1. Open your PDF: Launch WPS Office and open your interactive PDF form document.
  2. 2. Access PDF Form Tools: Navigate to the 'Form' tab on the top ribbon to view all available form fields and interactive elements.
  3. 3. Fill and Edit: Click into the date, text, or calculation fields to input your data directly.
  4. 4. Save or Export: Once completed, click 'Save' or export your filled PDF form to share it securely.
Seamlessly fill and manage interactive PDF formsHighly compatible with standard Adobe PDF document formatsLightweight, fast, and completely free to downloadMulti-platform support across Windows, Mac, Linux, and mobile
microsoft office alternative - wps office

Frequently Asked Questions

Why do JavaScript months start at 0 in Adobe Acrobat?

Adobe Acrobat utilizes standard JavaScript for form calculations. In JavaScript, the Date object is designed with a zero-based index for months, meaning January is 0 and December is 11, while days and years remain 1-based.

What is the difference between new Date() and util.scand() in Acrobat?

The new Date() function is a standard JavaScript method used universally across web and app development. In contrast, util.scand() is a proprietary Acrobat method specifically designed to parse custom formatted date strings (e.g., "mm/dd/yyyy") into JavaScript Date objects.

How do I trigger the JavaScript date calculation in my PDF form?

You can trigger the calculation automatically by placing the script in the field that displays the result. Go to the field's Properties > Calculate tab, and select 'Custom calculation script'. It will execute whenever the linked date field values change.