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.
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
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.
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
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?
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!
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.
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.
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.
Copy link to clipboard
Copied
I have no clue of how to create that. Would you mind helping?
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)
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
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; }
Copy link to clipboard
Copied
The last line of the code does nothing, and is also not set up correctly.