How to Copy and Reformat Dates in Acrobat PDF Form Fields
Question details
The user needs to automatically copy a date entered in one PDF form field (like mm/dd/yyyy) and display it in a different format (like the day of the week) in another field.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form where entering a birth date in one text field automatically populates another text field with the corresponding day of the week.
- Observed behavior
- Passing the source field object directly to formatting functions fails. The date string must be explicitly parsed before it can be reformatted for the destination field.
Ensure you have a PDF editor that supports form editing and JavaScript calculations, and note the exact field name of your source date field before proceeding.
Use a Custom JavaScript Calculation to Parse and Reformat
Apply a custom calculation script on the destination field to extract the string, parse it into a date object, and format it properly.
Acrobat JavaScript requires explicitly converting form field values into Date objects before applying new formats. Using util.scand reads the original string, while util.printd outputs your desired format.
Open your PDF in form editing mode, right-click the destination field where you want the day of the week to appear, and select 'Properties'.
In the Text Field Properties dialog box, click on the 'Calculate' tab and select the 'Custom calculation script' radio button.
Click the 'Edit' button next to the custom calculation script option to open the JavaScript Editor window.
Input the following script, replacing 'SourceDate' with your actual field name: var d = this.getField('SourceDate').valueAsString; if (d) { var dateObj = util.scand('mm/dd/yyyy', d); event.value = util.printd('dddd', dateObj); } else { event.value = ''; }

Create and Manage Interactive PDF Forms with WPS Office
WPS Office includes a robust PDF editor that allows you to seamlessly create interactive forms, modify field properties, and manage document data without needing complicated or expensive software.
- 1. Open PDF in WPS Office: Launch WPS Office and open your PDF document. Navigate to the 'Form' tab on the top ribbon.
- 2. Add Form Fields: Click on 'Text Field' or 'Date Field' to insert interactive elements directly onto your document pages.
- 3. Customize Field Properties: Double-click any newly inserted field to open its properties, where you can define field names, appearances, and specific formats.
- 4. Save and Distribute: Once your fields are configured, save your PDF. The interactive form will remain fully compatible with all standard PDF readers.

Frequently Asked Questions
Why does my destination date field show a blank or an error?
If you pass the field object directly instead of a parsed Date object, the formatting function cannot read it. You must extract the value using valueAsString and parse it with util.scand first.
What format code should I use to display the day of the week?
To output the full name of the day (such as Thursday), use the format code 'dddd' within your util.printd function.
Can I simply duplicate the date exactly as entered?
Yes, if you do not need to reformat the date into a day of the week, you can set the destination field's calculation to simply mirror the source field's value without writing custom JavaScript parsing.




