PDF Editing Issues

How to Automatically Display the Current Date and Time When a PDF Opens

Nimra MalikNimra Malik Oct 28, 2026 869 views

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.

How to Automatically Display Current Date and Time Upon Opening a PDF
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.
Before you start

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.

Solution 1Recommended

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.

1
Prepare the Form Field

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).

2
Access Document JavaScripts

Navigate to the top menu and select 'Tools' > 'JavaScript'. From the JavaScript toolbar, click on 'Document JavaScripts'.

3
Create the Script

In the dialog box, type a name for your script (e.g., "AutoDate") and click 'Add'. The JavaScript Editor will open.

4
Enter the JavaScript Code

Delete any default code and paste the following snippet: this.getField("Today").value = util.printd("mm/dd/yyyy HH:MM", new Date());

5
Save and Test

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.

Add a Document-Level JavaScript in Adobe Acrobat
JavaScript Permissions Required: For this automation to work, end-users must have JavaScript execution enabled in their PDF reader's security preferences.
WPS PDF Editor

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. 1. Open WPS Office: Launch the WPS Office desktop application and select the 'PDF' tab from the home screen workspace.
  2. 2. Open Your PDF File: Click 'Open' and select the PDF document you wish to edit, fill out, or manage.
  3. 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. 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.
Easily insert text fields, dates, and digital signatures without complex coding.Seamless compatibility with standard interactive PDF forms and elements.Fully compatible with Microsoft Office formats like Word, Excel, and PowerPoint.Lightweight application that opens large, interactive PDF files instantly.
QA img-9

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.