How to Automatically Display the Current Date and Time When a PDF Opens
Question details
The user needs to configure a PDF document to automatically insert the current date and time into a specific form field the moment the file is opened.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating interactive PDF forms that require a dynamic timestamp to reflect exactly when the user opened the document.
- Observed behavior
- The designated PDF form field dynamically populates with the current system date and time via a JavaScript trigger upon opening the file.
Ensure your PDF document is prepared with a designated text form field (e.g., named "Today") to receive the date string, and that you have a PDF editor like Adobe Acrobat Pro capable of editing document-level scripts.
Add a Document-Level JavaScript in Adobe Acrobat
Use Acrobat's built-in JavaScript tools to assign a date-generating script to the document's open action.
By utilizing Adobe Acrobat's Document JavaScripts feature, you can execute a script exactly when the document is initialized by the reader. This ensures the timestamp is always current the moment the file is viewed.
Open your PDF in Adobe Acrobat, navigate to the 'Prepare Form' tool, and ensure you have a text field created. Name this text field exactly "Today" (or note your specific field name to update the script accordingly).
Navigate to the top menu and select 'Tools' > 'JavaScript'. From the JavaScript toolbar, click on 'Document JavaScripts'.
In the dialog box, type a name for your script (e.g., "AutoDate") and click 'Add'. The JavaScript Editor will open.
Delete any default code and paste the following snippet: this.getField("Today").value = util.printd("mm/dd/yyyy HH:MM", new Date());
Click 'OK' to save the script, then close the Document JavaScripts window. Save the PDF file, close it, and reopen it with JavaScript enabled to verify the "Today" field populates with the current date and time.

Manage Interactive PDF Forms Easily with WPS Office
While adding complex document-level JavaScript requires advanced tools, WPS Office provides a comprehensive PDF Editor that allows you to easily create, fill, and manage interactive forms natively.
- 1. Open WPS Office: Launch the WPS Office desktop application and select the 'PDF' tab from the home screen workspace.
- 2. Open Your PDF File: Click 'Open' and select the PDF document you wish to edit, fill out, or manage.
- 3. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to easily add and edit text fields, checkboxes, and interactive areas natively.
- 4. Save Your Document: Once your interactive fields are prepared or filled, click the 'Save' icon in the top left corner to apply your changes securely.

Frequently Asked Questions
Why isn't the date updating when I open the PDF on a mobile device?
Many mobile PDF readers do not support or automatically disable document-level JavaScript for security and performance reasons. Ensure you are using a fully featured desktop PDF reader, or check if your mobile reader explicitly allows JS execution.
Can I change the date format displayed in the form field?
Yes, you can modify the date format string within the JavaScript code. For example, changing "mm/dd/yyyy HH:MM" to "dd-mmm-yyyy" will display the date in a format like 01-Jan-2024 instead.
Do I need to click the form field for the date to appear?
No. Because the script is added as a Document-level JavaScript that runs on the document's open event, the current date and time will populate automatically as soon as the file finishes loading.
What happens if the user saves the PDF after the date is generated?
If the user saves the PDF, the currently filled date becomes part of that saved version. However, the next time the file is opened, the script will execute again and overwrite the field with the new current date and time.




