Highlighted

Add 1 min to time field with HH:MM format

New Here ,
Nov 13, 2020

Copy link to clipboard

Copied

Hi,

I do not know Javascript and would really appreciate if you can help me how  I can autocalculate with adobe acrobat form.  Here is what I want:

End time1 = 23:30 #this is in HH:MM format and should be entered manually

Start time2= 23:31 #this is in HH:MM format,  should be autocalculated, and is equal to End time1 + 1 minute.

 

Thanks in advance.

 

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Try this code as the custom calculation script of "Start time2":

 

var endTime = this.getField("End time1").valueAsString;
if (endTime=="") event.value = "";
else {
	var d = util.scand("mm/dd/yyyy HH:MM", "01/01/2020 " + endTime);
	d.setTime(d.getTime()+60000);
	event.value = util.printd("HH:MM", d);
}
TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

35

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

Add 1 min to time field with HH:MM format

New Here ,
Nov 13, 2020

Copy link to clipboard

Copied

Hi,

I do not know Javascript and would really appreciate if you can help me how  I can autocalculate with adobe acrobat form.  Here is what I want:

End time1 = 23:30 #this is in HH:MM format and should be entered manually

Start time2= 23:31 #this is in HH:MM format,  should be autocalculated, and is equal to End time1 + 1 minute.

 

Thanks in advance.

 

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Try this code as the custom calculation script of "Start time2":

 

var endTime = this.getField("End time1").valueAsString;
if (endTime=="") event.value = "";
else {
	var d = util.scand("mm/dd/yyyy HH:MM", "01/01/2020 " + endTime);
	d.setTime(d.getTime()+60000);
	event.value = util.printd("HH:MM", d);
}
TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

36

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
Nov 13, 2020 0
Most Valuable Participant ,
Nov 13, 2020

Copy link to clipboard

Copied

Try this code as the custom calculation script of "Start time2":

 

var endTime = this.getField("End time1").valueAsString;
if (endTime=="") event.value = "";
else {
	var d = util.scand("mm/dd/yyyy HH:MM", "01/01/2020 " + endTime);
	d.setTime(d.getTime()+60000);
	event.value = util.printd("HH:MM", d);
}

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...
Nov 13, 2020 0
VeraMEV LATEST
New Here ,
Nov 13, 2020

Copy link to clipboard

Copied

This worked like a charm! Thank you very much.

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...
Nov 13, 2020 0