PDF Editing Issues

Format a User-Selected Date with Ordinal Suffixes in Adobe Acrobat

Amos GikundaAmos Gikunda Nov 19, 2026 869 views

Question details

Format a date entered in an Acrobat form with the correct ordinal suffix, such as 4th of February 2022.

Format a User-Selected Date with Ordinal Suffixes in Adobe Acrobat
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A form user enters a date, and the form displays it as a day with an ordinal suffix followed by the month and year.
Observed behavior
The suffix should be calculated from the entered date, not from the current date.
Before you start

Open the PDF in an Acrobat version that can edit form fields, and decide which numeric date format users will enter, such as d/m/yyyy. Make sure JavaScript is enabled in Acrobat or Reader when testing the form.

Solution 1Recommended

Add a custom validation script to the Acrobat date field

Use this script to calculate the suffix from the date entered by the user.

The script treats 11, 12, and 13 as exceptions and gives them the suffix th. It does not use the computer's current date.

1
Open the field properties

In Acrobat, open the PDF and select All tools > Prepare a form. Double-click the date field to open its properties.

2
Remove conflicting formatting

On the Format tab, select None so a built-in date format does not overwrite the script's text output.

3
Add the validation script

On the Validate tab, select Run custom validation script, click Edit, and paste this script: if (event.value) { var oDate = util.scand("d/m/yyyy", event.value); if (oDate != null) { var day = oDate.getDate(); var suffix; if (day == 11 || day == 12 || day == 13) suffix = "th"; else if (day % 10 == 1) suffix = "st"; else if (day % 10 == 2) suffix = "nd"; else if (day % 10 == 3) suffix = "rd"; else suffix = "th"; event.value = day + suffix + util.printd(" of mmmm yyyy", oDate); } }

4
Test the field

Close the field properties, preview the form, enter 4/2/2022, and move out of the field. The displayed result should be 4th of February 2022. Also test dates such as 11/2/2022 and 21/2/2022.

Add a custom validation script to the Acrobat date field
Match the input format: Change d/m/yyyy in util.scand() if the form uses a different input format. To change a formatted value, replace the field contents with a new date in the expected numeric format.
Free Microsoft Office alternative

Work with PDFs and Office documents in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Microsoft Office files. Its format compatibility helps make migration straightforward. The Acrobat-specific JavaScript solution above should be configured and tested in Acrobat.

Open and review PDF forms alongside other documentsCompatible with Microsoft Office formats, including DOCX, XLSX, and PPTXFamiliar interface makes it easy to move between document tasksFree, lightweight office suite for everyday work
microsoft office alternative - wps office

Frequently Asked Questions

Why is the script using the wrong date?

A script that calls new Date() uses the current date. Use util.scand() on event.value instead to parse the date entered in the form field.

How do I change the expected date input format?

In the field's Validate tab, edit the custom script and change the mask in util.scand(), for example from d/m/yyyy to m/d/yyyy. Tell users which format to enter.

How does the script handle 11th, 12th, and 13th?

It checks those three days first and assigns th before checking the final digit. This prevents results such as 11st or 12nd.

Why doesn't the formatted date appear when I test the form?

Check that JavaScript is enabled, the script is on the field's Validate tab, and the entered date matches the util.scand() mask. On the Format tab, select None to avoid conflicting built-in formatting.