Displaying the current Date

By using Acrobat Form Fields it is possible to display the current system date in a
field, best of all this field will dynamically update even in Acrobat Reader.

Add a Form field of type Text to the page and call it ‘mydate’ (see Figure 1.1).

Figure 1.1

Now select the ‘Set Page Action…’ from the ‘Document’ menu (see Figure 1.2).

Figure 1.2

Select ‘Page Open’ and click the ‘Add’ button (see Figure 1.3).

Figure 1.3

From the list of ‘Types’ select Javascript and click the ‘Edit’ button (see Figure 1.4).

Figure 1.4

Figure 1.5

Add the following code to Page Open Action (see Figure 1.5):


var newdate = new Date();
var thisfieldis = this.getField('mydate');

var theday = util.printd('dddd',newdate);
var thedate = util.printd('d',newdate);
var themonth = util.printd('mmmm',newdate);
var theyear = util.printd('yyyy',newdate);

thisfieldis.value = theday + ' ' + thedate + ', ' + themonth + ' ' + theyear ;

Now whenever the page is opened it will display the current system date.

Note: Experiment with the ‘dddd’, ‘mmmm’, ‘yyyy’ to get different date formats.

You May Also Like

About the Author: Dave Wraight

Leave a Reply