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

Day of Week Date Display (Full date display)

Community Beginner ,
Jun 10, 2024 Jun 10, 2024

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?

TOPICS
JavaScript , PDF , PDF forms

Views

316

Translate

Translate

Report

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

correct answers 1 Correct answer

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.

Votes

Translate

Translate
Community Expert ,
Jun 10, 2024 Jun 10, 2024

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Thanks!

What custom function should I write for the suffixes?

Votes

Translate

Translate

Report

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

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

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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