These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Current Date not working

lee82
Registered: Mar 2 2010
Posts: 5

Hi,

I have a textfield on my first page in pdf named DateField.
Then i went to Advanced >> Javascript >> Document Javascripts and added the following code:

var fld = this.getField("DateField");
fld.value = util.printd("yyyy/mm/dd",new Date());

Now as far as i understand, this is supposed to print the current date.
I added it on March 02 and it displayed fine, but when i opened it the next day, it still said 02 instead of 03.

How do automatically update the date when pdf is opened.

Thank you!

Lee

My Product Information:
Acrobat Pro 7.0, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2399
Is the script located inside a function?

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
When you add a document level JavaScript, Acrobat creates an empty function. If you put your code within the brackets of the function, you will need to call the function by name. If you removed the empty function the code should fill in the date. You will also have to have JavaScript enabled for the Acrobat application.

// document level functionfunction FillDate(){var fld = this.getField("DateField");fld.value = util.printd("yyyy/mm/dd",new Date());}// now call the function upon opening the PDF.FillDate();

You might want to consider putting the code in the document 'Will Print' action. Then the date field is only filled and displayed at the time the printing of the form is initiated.

George Kaiser