PDF Editing Issues

Format a PDF Date Field With Ordinal Suffixes in Adobe Acrobat

Steve KSteve K Nov 19, 2026 869 views

Question details

The user wants a PDF form date field to display dates with ordinal suffixes, such as “3rd Day of March 2022.”

Format a PDF Date Field With Ordinal Suffixes in Adobe Acrobat
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A PDF form needs to display a date using a day number, ordinal suffix, month name, and year.
Observed behavior
Acrobat’s built-in date formats do not automatically add ordinal suffixes.
Before you start

Open the PDF in an Acrobat version that supports editing form fields, and make sure JavaScript is enabled in Acrobat preferences. The script below expects dates entered as MM/DD/YYYY, with a year from 1000 through 9999.

Solution 1Recommended

Add a custom JavaScript format to the Acrobat date field

Use this method to display a date with the correct ordinal suffix while accounting for the 11th, 12th, and 13th.

1
Open the form field

In Acrobat, open the PDF and select Prepare a form. Double-click the date field to open its Properties.

2
Choose a custom format

In the field Properties dialog, open the Format tab. Choose Custom from the format category list, then select Edit next to Custom Format Script.

3
Enter the format script

Paste this script into the JavaScript editor and select OK: var input = String(event.value); var match = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(input); if (match) { var month = Number(match[1]); var day = Number(match[2]); var year = Number(match[3]); var date = new Date(year, month - 1, day); if (year >= 1000 && month >= 1 && month <= 12 && date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day) { var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; var suffix = "th"; if (day % 100 < 11 || day % 100 > 13) { if (day % 10 === 1) suffix = "st"; else if (day % 10 === 2) suffix = "nd"; else if (day % 10 === 3) suffix = "rd"; } event.value = day + suffix + " Day of " + months[month - 1] + " " + year; } }

4
Save and test the field

Close Properties, select Preview in Prepare a form, and enter 03/03/2022. Move out of the field to check that it displays “3rd Day of March 2022.” Also test dates on the 11th, 12th, 13th, 21st, and 31st, then save the PDF.

Add a custom JavaScript format to the Acrobat date field
Input and viewer limitations: The script leaves entries that do not match MM/DD/YYYY or are not valid calendar dates unchanged; it does not reject them. The formatting also requires a PDF viewer that supports Acrobat JavaScript and allows it to run.
Free Microsoft Office alternative

Work with PDFs and Office files in WPS Office

WPS Office is a free, lightweight alternative for everyday PDF and document work. Its familiar interface and support for common Microsoft Office formats make it easy to move between files, although it does not configure Acrobat’s custom date-field script.

Open and work with PDF documents alongside your office filesCompatible with Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTXFamiliar interface for a smoother transition from Microsoft OfficeFree and lightweight tools for everyday document tasks
microsoft office alternative - wps office

Frequently Asked Questions

Can Acrobat add ordinal suffixes using its built-in date formats?

No. To display suffixes such as “st,” “nd,” “rd,” and “th,” open the field’s Properties, select Format, and use a Custom Format Script.

Why does the script use “th” for the 11th, 12th, and 13th?

Those day numbers are exceptions to the usual last-digit rule. The script checks for 11 through 13 before applying “st,” “nd,” or “rd.”

What happens if someone enters a date in a different format?

The provided script only formats valid dates entered as MM/DD/YYYY. Other entries remain unchanged; add separate validation if you need to reject them.

Why might the formatted date not appear in another PDF viewer?

The viewer must support Acrobat JavaScript and allow it to run. Test the form in Acrobat with JavaScript enabled if the custom formatting does not appear.