Highlighted

Time calculations in adobe acrobat pro dc.

New Here ,
Nov 13, 2016

Copy link to clipboard

Copied

I am have the hardest time figuring this out.  Two whole days.  I am trying to configure time and setting it in regular time. 

So what I need is as follows

Date                      Time in               time out       Total Time

September 1          8:00am                2:30pm         6:30 and or 6.5

But every time I put in any calculations it does not come out correct.

Please help

I can actually send you the PDF to make this seem easier.

Adobe Community Professional
Correct answer by gkaiseril | Adobe Community Professional

I believe the issue is about computing the elapsed time or the time worked.

The OP's use of the simplified field notation does not work because there are non-numeric characters in the values being processed. In order for values to be processed in the Simplified Field Notation they must consist of an option sign ( + or -) numeric digits and optional decimal point and more digits. The presence of the ":" makes the value a string and dropped from the calculation. Only Custom JavaScript code can process this type of data.

The approach for the coding is converting the time into the JavaScript date object, This object contains or can compute various information about the date. It also has assigns a unique value to every millisecond. This number can be used to compute the difference between to date time combinations or compute a future date time combination.

There is a limited second way to computer time differences by parsing the time strings into hours and minutes and then doing the needed math. This method is very limited and cannot be used if the time interval includes the period of time when Day Light Savings Time change occurs or one is computing the time difference involving 2 different time zones.

See Thom Parker's Working with date and time in Acrobat JavaScript (Part 1 of 3), Working with date and time in Acrobat JavaScript (part 2 of 3) , Working with date and time in Acrobat JavaScript (part 3 of 3)

Adobe Acrobat JavaScript API Reference util.scand

Mozilla Development Network JavaScript Reference Date object

TOPICS
PDF forms

Views

4.2K

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

Time calculations in adobe acrobat pro dc.

New Here ,
Nov 13, 2016

Copy link to clipboard

Copied

I am have the hardest time figuring this out.  Two whole days.  I am trying to configure time and setting it in regular time. 

So what I need is as follows

Date                      Time in               time out       Total Time

September 1          8:00am                2:30pm         6:30 and or 6.5

But every time I put in any calculations it does not come out correct.

Please help

I can actually send you the PDF to make this seem easier.

Adobe Community Professional
Correct answer by gkaiseril | Adobe Community Professional

I believe the issue is about computing the elapsed time or the time worked.

The OP's use of the simplified field notation does not work because there are non-numeric characters in the values being processed. In order for values to be processed in the Simplified Field Notation they must consist of an option sign ( + or -) numeric digits and optional decimal point and more digits. The presence of the ":" makes the value a string and dropped from the calculation. Only Custom JavaScript code can process this type of data.

The approach for the coding is converting the time into the JavaScript date object, This object contains or can compute various information about the date. It also has assigns a unique value to every millisecond. This number can be used to compute the difference between to date time combinations or compute a future date time combination.

There is a limited second way to computer time differences by parsing the time strings into hours and minutes and then doing the needed math. This method is very limited and cannot be used if the time interval includes the period of time when Day Light Savings Time change occurs or one is computing the time difference involving 2 different time zones.

See Thom Parker's Working with date and time in Acrobat JavaScript (Part 1 of 3), Working with date and time in Acrobat JavaScript (part 2 of 3) , Working with date and time in Acrobat JavaScript (part 3 of 3)

Adobe Acrobat JavaScript API Reference util.scand

Mozilla Development Network JavaScript Reference Date object

TOPICS
PDF forms

Views

4.2K

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, 2016 0
Most Valuable Participant ,
Nov 14, 2016

Copy link to clipboard

Copied

Please let us know script you currently have to calculate, and then we can hopefully help you understand how to fix it. Also please give the formats of the input and output fields, and where you set the script. Also, what do you expect your users to ACTUALLY TYPE in the field?

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 14, 2016 0
New Here ,
Nov 14, 2016

Copy link to clipboard

Copied

I am subtracting both times (Feild13-Feild1)

The formats are HH:MM:tt

I expect my employees to type in 8:00 am(start time) and 5:00 pm (end time)

thank you for the help!

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 14, 2016 0
New Here ,
Nov 15, 2016

Copy link to clipboard

Copied

Test Screen, can I send you my document by email so that we can discuss exactly what I need.  I am trying alot of the suggestions but it is not working the way I need.

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 15, 2016 0
Adobe Community Professional ,
Nov 14, 2016

Copy link to clipboard

Copied

Do you ever expect the time entries to include 1:00am to 3:00am?

If so on certain date you will need to adjust for time changes brought about by Day Light Savings Time.

Will the elapsed time value ever be negative?

What results are you getting?

Have you looked at the Acrobat JavaScript API Reference, the Mozilla JavaScript Reference, and Thom Parkers series on date and time calculations at Acrobat Users?

This calculation can only be done using Custom JavaScirpting.

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 14, 2016 0
Adobe Community Professional ,
Nov 14, 2016

Copy link to clipboard

Copied

I expect my employees to type in 8:00 am(start time) and 5:00 pm (end time)

It is easier to get a correct preformatted input via a listbox or a JavaScript drop down menu.

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 14, 2016 0
New Here ,
Nov 14, 2016

Copy link to clipboard

Copied

I have no clue of how to create that.  Would you mind helping?

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 14, 2016 0
Adobe Community Professional ,
Nov 15, 2016

Copy link to clipboard

Copied

Creating a listbox is well explained in Acrobat's Help.

For a JavaScript drop down you can start here (clic the "Ressources" links): create drop down menu (PDF Forms)

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 15, 2016 0
Adobe Community Professional ,
Nov 15, 2016

Copy link to clipboard

Copied

I believe the issue is about computing the elapsed time or the time worked.

The OP's use of the simplified field notation does not work because there are non-numeric characters in the values being processed. In order for values to be processed in the Simplified Field Notation they must consist of an option sign ( + or -) numeric digits and optional decimal point and more digits. The presence of the ":" makes the value a string and dropped from the calculation. Only Custom JavaScript code can process this type of data.

The approach for the coding is converting the time into the JavaScript date object, This object contains or can compute various information about the date. It also has assigns a unique value to every millisecond. This number can be used to compute the difference between to date time combinations or compute a future date time combination.

There is a limited second way to computer time differences by parsing the time strings into hours and minutes and then doing the needed math. This method is very limited and cannot be used if the time interval includes the period of time when Day Light Savings Time change occurs or one is computing the time difference involving 2 different time zones.

See Thom Parker's Working with date and time in Acrobat JavaScript (Part 1 of 3), Working with date and time in Acrobat JavaScript (part 2 of 3) , Working with date and time in Acrobat JavaScript (part 3 of 3)

Adobe Acrobat JavaScript API Reference util.scand

Mozilla Development Network JavaScript Reference Date object

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 15, 2016 0
Nov 29, 2020

Copy link to clipboard

Copied

Hello, I am getting negative numbers with this calculation.

I.e. start 22:45 End 03:15 result is -20:30 instead 04:30 I am trying to do flight time calculation departure time is 22:45 arrival time 03:15 next day, I need total hours flown

 

var hrsStart = parseInt(this.getField("time2_1").value.split(":")[0]); var minStart = parseInt(this.getField("time2_1").value.split(":")[1]); var hrsEnd = parseInt(this.getField("time4_1").value.split(":")[0]); var minEnd = parseInt(this.getField("time4_1").value.split(":")[1]); if (minStart > minEnd) { var minRez = 60 + minEnd - minStart; var hrsRez = hrsEnd - 1 - hrsStart; } else { var minRez = minEnd - minStart; var hrsRez = hrsEnd - hrsStart; } this.getField("flight1").value = hrsRez + ":" + minRez; if(flight1 < 0) {// Shift 24 hours flight1 += 24; }

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 29, 2020 0
try67 LATEST
Most Valuable Participant ,
8 hours ago

Copy link to clipboard

Copied

The last line of the code does nothing, and is also not set up correctly.

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...
8 hours ago 0