Copy link to clipboard
Copied
Hello,
I'll just preface this by saying I have zero coding experience and almost no knowledge of javascript. I've been trying to create a custom stamp in Adobe Acrobat for work. I have an image that I have added a date/time calculation to, but somewhere in the code, something must be broken. I need the date format to be: 2018 MONTH DAY. Could someone please tell me how I can fix this? I also need the entire string to be capitalized, which seems to be working - it's just the date format I cannot figure out.
event.value = event.value.toUpperCase(event.value = util.printd("yyyy mm dd tt h:MM", new Date));
I thought "yyyy mm dd" would work, but it shows the date as MAY 23 2018.
Any help is appreciated.
You could do your scripts with more steps and observe what is happening. You might want to work on the script using the JavaScript console and not the field calculation until you have the script worked out.
I would start out and get the system date.
// get the system date object;
var oDate = new Date();
console.println(oDate);
Then format the date object as needed.
// format the date object;
var cDate = util.printd("yyyy mm dd tt h:MM", oDate);
console.println(cDate);
And finally capitalize the string.
//
...Copy link to clipboard
Copied
You could do your scripts with more steps and observe what is happening. You might want to work on the script using the JavaScript console and not the field calculation until you have the script worked out.
I would start out and get the system date.
// get the system date object;
var oDate = new Date();
console.println(oDate);
Then format the date object as needed.
// format the date object;
var cDate = util.printd("yyyy mm dd tt h:MM", oDate);
console.println(cDate);
And finally capitalize the string.
// capitalize the formatted string;
cDate = cDate.toUpperCase();
console.println(cDate);
Once you get it the way you want then add it to your stamp without the debugging statements.
// get the system date object;
var oDate = new Date();
// format the date object;
var cDate = util.printd("yyyy mm dd tt h:MM", oDate);
// capitalize the date object and set the field's value;
event.value = cDate.toUpperCase();
Copy link to clipboard
Copied
That worked! Thank you!