Skip to main content
ashleyh83908284
Participant
May 23, 2018
Answered

Format date calculation

  • May 23, 2018
  • 1 reply
  • 801 views

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.

This topic has been closed for replies.
Correct answer gkaiseril

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();

1 reply

gkaiserilCorrect answer
Inspiring
May 24, 2018

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();

ashleyh83908284
Participant
May 24, 2018

That worked! Thank you!