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

JavaScript - CreationDate converting to Date

New Here ,
Nov 03, 2025 Nov 03, 2025

I am currently working on an automation process for my department to take a large mail merge document and save each individual letter to the respective folder for each permit/customer.  Part of our document management rules require that every document have the creation date encoded in the file name.  Not difficutl, but as I won't always get to this step the same day the document is created, I am trying to extract the Creation Date from the Document Info.  However, I keep running into a wall on this.  Here is my sample code and the output from it:

 

var s = this.info.CreationDate;
console.println(s.toString());
var d = util.scand("ddd mmm dd yyyy",s.toString());
if (d == null) {console.println("Date Conversion Failed!");} else{console.println(d);}
d = util.scand("ddd mmm dd yyyy HH:MM:ss",this.info.CreationDate);
console.println(d);

Fri Sep 26 2025 10:58:59 GMT-0500 (Central Daylight Time)
Mon Nov 03 2025 10:58:59 GMT-0600 (Central Standard Time)
Mon Nov 03 2025 10:58:59 GMT-0600 (Central Standard Time)

true

 

I am banging my head against the wall trying to figure out what I'm doing wrong.  I have tried multiple variations on s.toString() and s as parameters, but the output is the same.

Any suggestions or tips would be greatly appreciated.

 Using Acrobat Pro 2020.

TOPICS
JavaScript , PDF
54
Translate
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
Community Expert ,
Nov 03, 2025 Nov 03, 2025

Part of the problem, is an issue with how date strings are parsed. You're date string contains extra things that are not needed, and that's the issue with converting that particular string. 

But the other, more important part of this issue, is that your code is completely unecessary.   The "creationDate" parameter is already a Date object. No coversion is needed. 

 

 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
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
Community Expert ,
Nov 03, 2025 Nov 03, 2025
LATEST

What exactly are you trying to do?  Display the Creation Date object in a specific format?  If so, use util.printd like this:

util.printd("ddd mmm dd yyyy HH:MM:ss",this.info.CreationDate);

Translate
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