How to Update PDF Form Date and Time Fields Before Saving
Question details
The user needs to automatically record the current date and time in a specific PDF form field right before the document is saved.

- Product
- Device & OS
- not provided
- Scenario
- A user is filling out, modifying, or preparing to send a PDF form and needs the timestamp to reflect the exact moment of saving.
- Observed behavior
- The user requires a mechanism to trigger a date and time update automatically upon the save action, rather than manually entering the timestamp.
Ensure your PDF editor supports JavaScript execution and verify the exact name of the text field designated for the date and time in your PDF form.
Use the Document Will Save JavaScript Action
Attach a JavaScript code snippet to the 'Document Will Save' event so the timestamp updates immediately before the save operation completes.
PDF documents allow you to trigger specific actions based on document events. By tying a date-generation script to the 'Document Will Save' event, you guarantee that the timestamp field always reflects the exact moment the file is written to the disk, without requiring a secondary save.
In your advanced PDF editor, navigate to the 'Tools' menu and select 'JavaScript' to access the scripting options.
Click on 'Set Document Actions' to open the dialog box that manages document-level event triggers.
From the list of available actions, highlight 'Document Will Save' and click the 'Edit' button.
Input the script to update your specific field. For example: var f = this.getField("YourDateFieldName"); f.value = util.printd("mm/dd/yyyy HH:MM:ss", new Date()); Then click 'OK' to apply.

Manage and Edit PDF Forms Seamlessly with WPS Office
WPS Office provides a comprehensive PDF toolkit that allows you to effortlessly view, fill, and modify PDF forms. With its lightweight design and intuitive interface, you can manage your PDF documents and ensure your forms are filled out correctly before sharing.
- 1. Open the PDF Form: Launch WPS Office and open your target PDF form document.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to view all available form editing and filling options.
- 3. Fill or Edit Fields: Click directly on the text or date fields to input your data, or use the form creation tools to adjust the layout.
- 4. Save and Export: Click the 'Save' icon in the top left corner to retain your inputted data before emailing or sharing the PDF.

Frequently Asked Questions
Why is my date field not updating when I save the PDF?
This usually happens if the field name referenced in your JavaScript does not match the actual field name in the PDF form, or if your current PDF reader has JavaScript execution disabled for security reasons.
Can I use the 'Document Did Save' action instead?
No. The 'Document Did Save' action runs after the file has already been written to your drive. If the script updates the date field at this stage, the new date will not be saved unless you trigger the save command a second time.
Will this JavaScript work on mobile PDF readers?
Support for PDF JavaScript varies greatly across devices. While fully supported in major desktop PDF editors, many mobile PDF readers or web browser-based viewers restrict or completely ignore JavaScript triggers.




