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

Format a Date Field to Another Formatting

Explorer ,
Jul 26, 2023 Jul 26, 2023

I worked on a Tool that can build PDF Forms. In this tool, I defined a DateTime field. I genereated an PDF Form which has a candenler that can allow user to choose the date. But the formatting is not what I wanted(see the image below). We wanted it shows MM/DD/YYYY

Blair285268942h5r_0-1690419129446.pngexpand image

I posted formatting issue before which is about currency formating, the code is like this:

var Minisalary = this.getField("MiniSalary");
Minisalary.setAction("Format", "event.value = formatCurrency(event.value);");

 

So, I am wondering if we can do simialir code, like below to realize it, but I tried serval ways, it failed. 

var date= this.getField("my field");
date.setAction("Format", "event.value = ???;");

 

 

 

TOPICS
How to , PDF forms
747
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
Explorer ,
Jul 27, 2023 Jul 27, 2023

Could you please help on the coding?

 

var Date= this.getField("StartDate");
Date.setAction("Format", "event.value = formatDate ("MM/DD/YYYY");");

 

I don't know what function should be used here.

 

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 ,
Jul 26, 2023 Jul 26, 2023

What version of Adobe Acrobat does you use?

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
Explorer ,
Jul 27, 2023 Jul 27, 2023

Adobo Pro DC

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 ,
Jul 27, 2023 Jul 27, 2023

There you can use the format "MM/DD/YYYY" for the date field. 

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
Explorer ,
Jul 27, 2023 Jul 27, 2023

Could you please help on the coding?

 

var Date= this.getField("StartDate");
Date.setAction("Format", "event.value = formatDate ("MM/DD/YYYY");");

 

I don't know what function should be used here.

 

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
Explorer ,
Jul 27, 2023 Jul 27, 2023
LATEST

Sorry for confusion, please ingore the currency fomatting, the function formatDate is user-defined. Anyhow, the problem is fixed, and using below code:

 

//Date format MM/DD/YYYY, Business is a subtree, CurrentDate is a field under it. That needs a '_' between them. 
var CurrentDate = this.getField("Business_CurrentDate");
var requiredFormat = "mm/dd/yyyy";
CurrentDate.setAction("Format", "AFDate_FormatEx(\""+requiredFormat+"\")");
CurrentDate.setAction("Keystroke", "AFDate_KeystrokeEx(\""+requiredFormat+"\")");

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