Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Day of Week Date Display (Full date display)

Community Beginner ,
Jun 10, 2024 Jun 10, 2024

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?

TOPICS
JavaScript , PDF , PDF forms
829
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Jun 10, 2024 Jun 10, 2024

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.

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 10, 2024 Jun 10, 2024

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 10, 2024 Jun 10, 2024

Thanks!

What custom function should I write for the suffixes?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 10, 2024 Jun 10, 2024

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

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2024 Jun 11, 2024
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines