Skip to main content
darrenrichie
Participant
Apr 8, 2016 9:14 AM UTC
Answered

Populate text field with current time upon signing

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 is closed to new replies. Start a new post to keep the conversation going.
George_JohnsonCorrect answer
Inspiring
Apr 9, 2016 6:04 PM UTC

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.

8 replies

George_JohnsonCorrect answer
Inspiring
Apr 9, 2016 6:04 PM UTC

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.

Translate
Participant
Jun 17, 2017 7:29 PM UTC

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!

Translate
Bernd Alheit
Community Expert
Community Expert
Jun 18, 2017 2:16 PM UTC

Why want you the name of the signature field?

Translate