Format date calculation

May 23, 2018

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.

Adobe Community Professional
Correct answer by gkaiseril | Adobe Community Professional

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

TOPICS
Acrobat SDK and JavaScript, Windows

Views

122

Likes

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

Format date calculation

May 23, 2018

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.

Adobe Community Professional
Correct answer by gkaiseril | Adobe Community Professional

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

TOPICS
Acrobat SDK and JavaScript, Windows

Views

123

Likes

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
May 23, 2018 0
Adobe Community Professional ,
May 23, 2018

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

Likes

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
Reply
Loading...
May 23, 2018 0
May 24, 2018

Copy link to clipboard

Copied

That worked! Thank you!

Likes

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
Reply
Loading...
May 24, 2018 0