How to Insert the Current Time When a PDF Form Field is Clicked
Question details
The user wants to record the exact time a PDF form field is clicked instead of the time the document was opened.

- Product
- Adobe Acrobat / PDF
- Device & OS
- not provided
- Scenario
- Creating or editing a PDF form that requires an accurate timestamp exactly when a specific field is interacted with.
- Observed behavior
- By default, simple time calculation scripts might capture the document opening time. The goal is to capture the time dynamically at the moment of the click.
Ensure you have permission to edit the PDF form fields and that your PDF editor supports JavaScript actions for interactive elements.
Add a Custom JavaScript to the Form Field's Mouse Up Event
Assign a script to the field's Mouse Up or Focus event to generate a dynamic timestamp exactly when the user clicks.
Using a default calculation script can mistakenly capture the time the document was initially opened. Instead, applying a JavaScript snippet to a specific user action (like 'Mouse Up') ensures the time is recorded precisely when the user clicks the field.
Right-click the target form field in your PDF editor (such as Adobe Acrobat) and select 'Properties' from the context menu.
Navigate to the 'Format' tab. Set the format category to 'Time' and choose your preferred time display format (e.g., HH:MM).
Go to the 'Actions' tab. Select 'Mouse Up' (or 'On Focus') as the trigger. Choose 'Run a JavaScript' as the action, and click the 'Add' button.
In the JavaScript Editor window, enter the following code exactly: event.value = util.printd("HH:MM", new Date()); Then click 'OK' to save.

Manage and Edit PDF Forms Seamlessly with WPS PDF
WPS Office provides a comprehensive suite of PDF tools, allowing you to easily view, fill, and manage PDF forms. It serves as a highly compatible and lightweight solution for all your document needs.
- 1. Open your PDF in WPS Office: Launch WPS Office and open your PDF document using the built-in WPS PDF editor.
- 2. Navigate to the Form tab: Select the 'Form' tab on the top ribbon to access form editing and filling features.
- 3. Fill or Insert Data: Click on the interactive fields to input data, or use the 'Insert Text' tool to manually type the current time if the form lacks dynamic script fields.

Frequently Asked Questions
Why does my PDF time field show the time the document was opened?
This happens if the field is using a calculation script that triggers on document load rather than a specific user action. Changing the script trigger to 'Mouse Up' resolves this issue.
Can I format the timestamp to include the current date as well?
Yes. You can change the JavaScript format string to include the date. For example, use util.printd("mm/dd/yyyy HH:MM", new Date()); and ensure you update the field's Format tab to accept date and time.
Does this JavaScript time insertion work on mobile PDF readers?
Custom JavaScript form actions are fully supported on desktop PDF editors like Adobe Acrobat, but many mobile PDF viewers restrict or do not support JavaScript execution for security and performance reasons.




