Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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);
Find more inspiration, events, and resources on the new Adobe Community
Explore Now