PDF Editing Issues

How to Show the Current Date and Time in a PDF Field on Mouse Up

Camila MilosovichCamila Milosovich Nov 5, 2026 869 views

Question details

The user wants to configure a PDF text field to automatically display the current date and time when clicked.

How to Show the Current Date and Time in a PDF Field on Mouse Up
Product
PDF Editors
Device & OS
not provided
Scenario
Creating an interactive PDF form that captures the exact time a user interacts with a specific field.
Observed behavior
A custom JavaScript trigger is required to fetch the system time and insert it into the target field upon releasing the mouse button.
Before you start

Ensure you are using a PDF editor that supports form creation and executing custom JavaScript, and switch your document to form editing mode.

Solution 1Recommended

Add JavaScript to the Field's Mouse Up Action

Use the built-in Acrobat JavaScript utility to fetch the current date and format it into the text field when triggered.

PDF forms support interactive elements through JavaScript. By binding a script to the 'Mouse Up' action, you guarantee the script executes the moment a user finishes clicking the field.

1
Open Field Properties

In your PDF form editor, right-click the target text field and select 'Properties' from the context menu.

2
Set the Action Trigger

Navigate to the 'Actions' tab within the Properties dialog. From the 'Select Trigger' dropdown, choose 'Mouse Up'.

3
Select JavaScript Action

From the 'Select Action' dropdown, choose 'Run a JavaScript', then click the 'Add' button.

4
Enter the Custom Script

In the JavaScript Editor window, paste the following code: event.target.value = util.printd("yyyy/mm/dd/HH:MM", new Date()); then click 'OK' and close the properties window.

Add JavaScript to the Field's Mouse Up Action
Adjusting the Date Format: In the formatting string 'yyyy/mm/dd/HH:MM', 'HH' represents the hour in a 24-hour format and 'MM' represents the minutes. You can rearrange these components to match your required display format.

Create and Manage Interactive PDF Forms with WPS Office

WPS Office provides a powerful PDF suite that allows you to view, fill, and manage interactive PDF forms with ease, ensuring high compatibility with standard PDF features.

  1. 1. Open your PDF Document: Launch WPS Office and open the PDF form you need to view or edit.
  2. 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access interactive field tools and filling options.
  3. 3. Interact with the Fields: Click on the designated form fields to enter your data or trigger any interactive timestamps embedded in the document.
  4. 4. Save the Completed Form: Once your data and timestamps are filled, click 'Save' or 'Save As' to store the updated PDF on your local drive.
Easily fill and interact with standard PDF formsHighly compatible with Adobe Acrobat document formatsLightweight application with a seamless user interfaceComprehensive tools to annotate, edit, and protect PDFs
microsoft office alternative - wps office

Frequently Asked Questions

Why does the date only update when I click the field?

Because the JavaScript is explicitly tied to the 'Mouse Up' trigger, it only executes when you perform a mouse click on that specific field. It does not act as a live, continuously ticking clock.

Can I format the time to a 12-hour AM/PM display?

Yes, you can modify the date format string in the JavaScript. Use 'h' for a 12-hour format and append 'tt' for the AM/PM indicator. For example: util.printd("yyyy/mm/dd h:MM tt", new Date());

Will this JavaScript work on mobile PDF readers?

Support for custom JavaScript varies across mobile PDF applications. While standard desktop PDF editors handle these scripts natively, many mobile readers do not fully support executing Acrobat JavaScript, which may prevent the date from auto-filling.

What is the difference between 'Mouse Up' and 'Mouse Down' in PDF forms?

'Mouse Down' triggers the moment the mouse button is pressed, while 'Mouse Up' triggers when the button is released. 'Mouse Up' is the standard best practice for interactive fields as it gives the user a fraction of a second to cancel the action by dragging the cursor away before releasing.