PDF Editing Issues

How to Make a PDF Date Update Automatically with JavaScript

Maira MehtabMaira Mehtab Oct 28, 2026 869 views

Question details

The user needs a PDF form field to automatically update with the current date and time every time the document is opened.

How to Automatically Update a PDF Date with JavaScript
Product
Adobe Acrobat Standard 2017
Device & OS
not provided
Scenario
Creating dynamic PDF forms that require a real-time timestamp or current date upon opening.
Observed behavior
A calculated PDF form field only displays the date and time from when it was initially configured and fails to refresh when the PDF is reopened.
Before you start

Ensure you have a PDF editor that supports JavaScript execution and form field creation, such as Adobe Acrobat. Verify the exact name of your date text field (e.g., 'Today') before applying the script.

Solution 1Recommended

Use a Document-Level JavaScript Action

A document-level script ensures the JavaScript executes every time the PDF is opened, rather than relying on a field calculation that only triggers when a value changes.

By default, standard calculation scripts trigger only when a related field's value is modified. To force the date to refresh unconditionally when the file opens, you must use a document-level initialization script.

1
Identify the target form field

Open your PDF and ensure you have a text field created to display the date. Note the exact field name, for example, 'Today'.

2
Open the JavaScript Console

Navigate to your PDF editor's JavaScript tools. In Acrobat Standard, look for the JavaScript Console or the Document Actions menu.

3
Add the document-level script

Add a new document-level script triggered on 'load'. Enter the following code: this.addScript("load", "this.getField('Today').value = util.printd('yyyy/mm/dd', new Date());");

4
Customize the field name and format

Ensure 'Today' perfectly matches your text field's name, and adjust 'yyyy/mm/dd' if you prefer a different date format.

5
Save and test

Save the PDF document, close it, and reopen it. The date field should now automatically populate with the current date.

Use a Document-Level JavaScript Action
JavaScript Support in PDF Viewers: Be aware that the automatic date update relies on the end-user's PDF viewer supporting JavaScript. Some basic web or mobile PDF viewers may not execute the script.
Easily Manage PDF Forms

Create and Manage Interactive PDF Forms with WPS PDF

WPS Office provides a robust PDF editor that allows you to easily insert text fields, manage interactive forms, and apply advanced formatting without needing expensive software.

  1. 1. Open your PDF in WPS Office: Launch WPS Office and click on 'PDF Edit' to load the document you want to modify.
  2. 2. Access the Form tools: Navigate to the 'Form' tab on the top ribbon to access all interactive field tools.
  3. 3. Insert a Text Field: Select 'Text Field' and draw the box on the page where you want your date or text to appear.
  4. 4. Modify field properties: Double-click the new field to access its properties, where you can rename it, format the text, or set it to read-only.
  5. 5. Save the interactive PDF: Click 'Save' to apply your form fields, making the document ready for users to fill out.
Seamlessly create, edit, and fill out interactive PDF forms.Highly compatible with standard Adobe PDF formats and features.Lightweight alternative to heavy and expensive PDF software.Free to use for everyday PDF reading, commenting, and editing tasks.
microsoft office alternative - wps office

Frequently Asked Questions

Why doesn't my calculated date field update when I open the PDF?

Calculated fields in standard PDF forms only trigger a refresh when a related field's value is changed. To update a date automatically strictly upon opening, you must use a document-level or page-action JavaScript instead.

Do all PDF readers support JavaScript date scripts?

No, some basic PDF readers, web browser plugins, and mobile viewers do not support executing embedded JavaScript. Users will need a standard PDF desktop application like Adobe Acrobat or WPS PDF to trigger dynamic scripts.

How do I change the format of the auto-updating date?

In the util.printd() function of your JavaScript code, you can change the format string. For example, replacing 'yyyy/mm/dd' with 'mm/dd/yyyy' or 'dd-mmm-yyyy' will change how the date displays to match your regional preferences.