Skip to main content
darrenrichie
Participant
April 8, 2016
Answered

Populate text field with current time upon signing

  • April 8, 2016
  • 1 reply
  • 2803 views

Hi

I have used the following script from another thread to auto populate a text field with current date upon signing of a PDF form:

// JavaScript code to add the date at signing time

    var currentTime = new Date()

    var month = currentTime.getMonth() + 1

    var day = currentTime.getDate()

    var year = currentTime.getFullYear()

    var signingTime = day +"/"+month+"/"+year  //Modify into your preferred format

    var f = this.getField("Text1");  //Modify the field name as necessary

    f.value = signingTime;

(Original thread Can Acrobat auto populate a date field upon digital signature of a form?‌ I didn't want to ask on there since the thread was so old.)

This is working fine but I also want to add the current time to the box. This is to validate when a document was signed before being submitted and will work on 3 different signatures.

Any ideas would be much appreciated.

This topic has been closed for replies.
Correct answer George_Johnson

A timestamp will be included as part of each digital signature, so this is redundant, but you script can be much simpler:

getField("Text1").value = util.printd("dd/mm/yyyy HH:MM", new Date());

More information on the util.printd method and the format characters you can use is in the Acrobat JavaScript reference.

1 reply

George_JohnsonCorrect answer
Inspiring
April 9, 2016

A timestamp will be included as part of each digital signature, so this is redundant, but you script can be much simpler:

getField("Text1").value = util.printd("dd/mm/yyyy HH:MM", new Date());

More information on the util.printd method and the format characters you can use is in the Acrobat JavaScript reference.

Participant
June 17, 2017

Do you know the javascript code for the "fullname" instead?

I also try to get the full name of the signature field and display next to the signature & date fields but I don't know how.  Please help.

Thanks!

Bernd Alheit
Community Expert
Community Expert
June 18, 2017

Why want you the name of the signature field?