Copy link to clipboard
Copied
I am preparing a form and want users to select dates.
When they do, I want the date displayed with the day of the week.
For example, if they select June 9th, 2024 from the date picker, I want it to display as Monday, June 20th, 2024.
How do I do this?
In the format tab select Date, then Custom, then enter the following into the field:
dddd, mmmm dd, yyyy
It won't give you the st, nd, rd in 1st, 2nd, 3rd, etc. You would have to write a custom function for that.
Copy link to clipboard
Copied
In the format tab select Date, then Custom, then enter the following into the field:
dddd, mmmm dd, yyyy
It won't give you the st, nd, rd in 1st, 2nd, 3rd, etc. You would have to write a custom function for that.
Copy link to clipboard
Copied
Thanks!
What custom function should I write for the suffixes?
Copy link to clipboard
Copied
In the format tab, enter the following custom format script:
AFDate_FormatEx("mm/dd/yyyy");
var date=util.scand("mm/dd/yyyy", event.value);
function ordinal(n)
{
var s = ['th', 'st', 'nd', 'rd'];
var m = n % 100;
return n + (s[(m - 20) % 10] || s[m] || s[0]);
};
event.value=util.printd("dddd, mmmm ",date)+
ordinal(util.printd("d",date))+
util.printd(", yyyy", date);
And enter the follow custom keystroke script:
AFDate_KeystrokeEx("mm/dd/yyyy");
These 2 articles explain how the custom format scripts work and how to find the scripts:
https://pdfautomationstation.substack.com/p/custom-format-for-pdf-fields
https://pdfautomationstation.substack.com/p/more-custom-formatting-for-pdf-fields
Copy link to clipboard
Copied
If you do that be aware that the code might "disappear" when entered. It should still work, though.
This happens when you use one of Acrobat's internal (undocumented) functions, such as AFDate_FormatEx.