How to Get the Day of the Week from a PDF Date Field
Question details
The user needs to retrieve the specific day of the week from an Acrobat date field using JavaScript.

- Product
- Adobe Acrobat / PDF Forms
- Device & OS
- not provided
- Scenario
- Writing a custom script within a PDF form to extract the weekday text from a field that contains a full date.
- Observed behavior
- When fetching the value from a date field that visually displays an abbreviated weekday, the script returns the full underlying date string instead of just the formatted weekday text.
Ensure your PDF editor supports JavaScript for forms and that you have the necessary permissions to edit the document-level scripts or form field properties.
Use JavaScript to Parse the Date Object and Extract the Weekday
By reading the field's underlying value as a Date object, you can use the standard JavaScript getDay() method to accurately determine the day of the week regardless of visual formatting.
In PDF forms, visual formatting applied to a date field only changes how the information is displayed on the screen. The actual data stored within the field remains the original date string.
To get the specific day of the week, you must retrieve that underlying string, convert it into a standard JavaScript Date object, and utilize the built-in Date methods.
Open your PDF in form editing mode, right-click the target field where you want the weekday to appear, and select 'Properties' to add a custom calculation script.
In your JavaScript editor, get the value of the date field by writing: var dateString = this.getField('YourDateFieldName').valueAsString;
Convert the retrieved string into a JavaScript Date object by using: var d = new Date(dateString);
Call the getDay() method on your Date object using: var dayNum = d.getDay(); This will return an integer between 0 (Sunday) and 6 (Saturday).
To display the actual text, create an array of days (e.g., var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];) and retrieve the name using days[dayNum].

Manage Interactive PDF Forms Seamlessly with WPS Office
If you are looking for a highly capable and user-friendly tool to handle PDF documents, WPS Office provides comprehensive PDF editing and form management features to streamline your workflow.
- 1. Open WPS PDF: Launch WPS Office and click on the 'PDF' module from the main dashboard.
- 2. Load Your Document: Open your target PDF file that contains the forms you need to manage.
- 3. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to begin interacting with, filling, or modifying form fields.
- 4. Save and Export: Once your data is entered, click 'Save' or use the export tools to share your finalized interactive document.

Frequently Asked Questions
Why does my date field only show the abbreviation but output the full date in scripts?
The visual formatting applied to a PDF form field only changes how the data is displayed to the user. The underlying value stored in the document remains the complete, unformatted date string.
What values does the JavaScript getDay() method return?
The getDay() method returns an integer between 0 and 6 representing the day of the week, where 0 is Sunday, 1 is Monday, and so on up to 6 for Saturday.
How can I make the script return 'Monday' instead of '1'?
You can define an array containing the days of the week in your script, such as ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']. Then, use the integer returned by getDay() as the index to pull the corresponding string from the array.




