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

Format date calculation

New Here ,
May 23, 2018 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.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

456

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
community guidelines

correct answers 1 Correct answer

LEGEND , May 23, 2018 May 23, 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.

//

...

Votes

Translate

Translate
LEGEND ,
May 23, 2018 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();

Votes

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
community guidelines
New Here ,
May 24, 2018 May 24, 2018

Copy link to clipboard

Copied

LATEST

That worked! Thank you!

Votes

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
community guidelines