Skip to main content
Participant
November 13, 2020
Answered

Add 1 min to time field with HH:MM format

  • November 13, 2020
  • 1 reply
  • 1018 views

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.

 

This topic has been closed for replies.
Correct answer try67

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);
}

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
November 13, 2020

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);
}
VeraMEVAuthor
Participant
November 13, 2020

This worked like a charm! Thank you very much.