How to Make a PDF Date Update Automatically with JavaScript
Question details
The user needs a PDF form field to automatically update with the current date and time every time the document is opened.

- 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.
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.
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.
Open your PDF and ensure you have a text field created to display the date. Note the exact field name, for example, 'Today'.
Navigate to your PDF editor's JavaScript tools. In Acrobat Standard, look for the JavaScript Console or the Document Actions menu.
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());");
Ensure 'Today' perfectly matches your text field's name, and adjust 'yyyy/mm/dd' if you prefer a different date format.
Save the PDF document, close it, and reopen it. The date field should now automatically populate with the current date.

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. Open your PDF in WPS Office: Launch WPS Office and click on 'PDF Edit' to load the document you want to modify.
- 2. Access the Form tools: Navigate to the 'Form' tab on the top ribbon to access all interactive field tools.
- 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. 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. Save the interactive PDF: Click 'Save' to apply your form fields, making the document ready for users to fill out.

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.




