Multiple date fields in pdf form but with different formats
I am creating a pdf form which has a date field (Date1). The same date field needs to appear as "mmmm dd, yyyy", "mm/dd/yyyy" and "yyyy-mm-dd" within the form. I want to change the date one time and have it update across the form using the various formats.
I found a post at
https://community.adobe.com/t5/acrobat/copy-date-to-field-with-different-formatting/td-p/10648920
which addresses the issue. I don't know Javascript but tried using the second suggested code:
You can also just try this line in the custom calculation script of BrthDate2 field:
var s = this.getField("BirthDate").valueAsString; <<<----------------------------NOTE THE USE OF valueAsString instead of .value
if (s=="") event.value = "";
else {
var d = util.scand("dd-mm-yyyy", s);
d.setDate(d.getDate()-0);
event.value = util.printd("dd/mmm/yyyy", d);
}
The second instance of the date (3Date) works as expected using:
var s = this.getField("Date1").valueAsString;
if (s=="") event.value = "";
else {
var d = util.scand("mm/dd/yyyy", s);
d.setDate(d.getDate()-0);
event.value = util.printd("mm/dd/yyyy", d);
}
BUT I cannot get the 3rd instance (Date4) to work. What am I missing? Below is the Custom Calculation Script:
var s = this.getField("Date1").valueAsString;
if (s=="") event.value = "";
else {
var d = util.scand("yyyy-mm-dd", s);
d.setDate(d.getDate()-0);
event.value = util.printd("yyyy-mm-dd", d);
}
Likes
