Show actual time

New Here ,
Dec 04, 2020

Copy link to clipboard

Copied

I am not sure if it is possible, I have a field that shows the time when the form was opened with the usual code:

 var c = this.getField("TimeStamp");
c.value = util.printd ("HH:MM", new Date());

 

But I would like the time to change as time goes on. The user could have opened the form at 10:00, but took 20 minutes to fill the form, so I would like to see the 10:20 time shown.

 

Is there a way to see the actual time in a field?

Adobe Community Professional
Correct answer by George_Johnson | Adobe Community Professional

Sure. You'd use the app.setInterval method. The code that it calls would be the same as you showed, but it easily be condensed to a single line. More information here: https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/#t=Acro12_MasterBook%2FJS_API_AcroJS%2Fapp_methods.htm%23TOC_setIntervalbc-34&rhtocid=_6_1_8_6_1_33

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

63

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Show actual time

New Here ,
Dec 04, 2020

Copy link to clipboard

Copied

I am not sure if it is possible, I have a field that shows the time when the form was opened with the usual code:

 var c = this.getField("TimeStamp");
c.value = util.printd ("HH:MM", new Date());

 

But I would like the time to change as time goes on. The user could have opened the form at 10:00, but took 20 minutes to fill the form, so I would like to see the 10:20 time shown.

 

Is there a way to see the actual time in a field?

Adobe Community Professional
Correct answer by George_Johnson | Adobe Community Professional

Sure. You'd use the app.setInterval method. The code that it calls would be the same as you showed, but it easily be condensed to a single line. More information here: https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/#t=Acro12_MasterBook%2FJS_API_AcroJS%2Fapp_methods.htm%23TOC_setIntervalbc-34&rhtocid=_6_1_8_6_1_33

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

64

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 04, 2020 0
Adobe Community Professional ,
Dec 04, 2020

Copy link to clipboard

Copied

Sure. You'd use the app.setInterval method. The code that it calls would be the same as you showed, but it easily be condensed to a single line. More information here: https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/#t=Acro12_MasterBook%2FJS_API_Acro...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 04, 2020 0
New Here ,
Dec 05, 2020

Copy link to clipboard

Copied

This worked well on the desktop.

However on iPad it doesn't work, but it might be due to a limitation on the iPad, otherwise it works.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 05, 2020 0
Most Valuable Participant ,
Dec 05, 2020

Copy link to clipboard

Copied

I don't think it's a good idea to do a timer that goes on constantly, at least not for the purpose you mentioned. Why not just update the "TimeStamp" field when the file is saved, for example? You can use the Will Save document event to do it.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 05, 2020 0
New Here ,
Dec 05, 2020

Copy link to clipboard

Copied

I know this would make more sense, however I want to use it on the iPad and the user is actually never saving the form. When they are done completeing the form, they just hit a "Submit" button that is from the iPad app to upload the form to a server, so there is no actual save process from the user.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 05, 2020 0
Most Valuable Participant ,
Dec 06, 2020

Copy link to clipboard

Copied

Then add it to the Submit button's Mouse Up action...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 06, 2020 0
New Here ,
Dec 06, 2020

Copy link to clipboard

Copied

The Submit button is not a button created in the form.

It is a button from the App itself.

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 06, 2020 0
New Here ,
Dec 06, 2020

Copy link to clipboard

Copied

Is there a way to have the time check/change everytime a field is filled or a button is clicked?

Would I have to put the code in each of the field to check time?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 06, 2020 0
try67 LATEST
Most Valuable Participant ,
Dec 06, 2020

Copy link to clipboard

Copied

Yes, if you place the code under the custom calculation script of the text field.

You can use this:

event.value = util.printd ("HH:MM", new Date());

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 06, 2020 0