Copy link to clipboard
Copied
i need this to happen automatically
start | shutdown | difference (decimal hours) |
---|---|---|
12:34 | 12:44 | 0.2 hours |
13:00 | 13:21 | 0.4 hours |
13:40 | 15:01 | 1.4 hours |
Copy link to clipboard
Copied
Time calculations are complicated. See these tutorials for a good starting point:
https://acrobatusers.com/tutorials/working-with-date-and-time-in-acrobat-javascript
https://acrobatusers.com/tutorials/working-with-date-and-time-in-acrobat-javascript-part-2
https://acrobatusers.com/tutorials/working-with-date-and-time-in-acrobat-javascript-part-3
If you're interested I've developed a tool that allows you to do it without having to write any code.
You can find it here: Custom-made Adobe Scripts: Acrobat -- Calculate Time Differences in a Worksheet
Copy link to clipboard
Copied
There are some additional issues you need to provide information about.
1. Will the time interval ever span more than 1 date?
If so, you will need to include the dates for the start and end.
2. You are rounding to the nearest 1/10th of an hour, since JavaScript uses IEEE floating point to store numbers, you will need to provide a rounding routine for the floating point number unless you can live with the fractional values in the result beyond 1/10th of an hour.
Copy link to clipboard
Copied
time will always span on the same day/date
and
we have predetermined time decimals ex:
from 1 to 6 = 0.1
from 6 to 14= 0.2
from 15 to 20=0.3
.....
Copy link to clipboard
Copied
With only hours an minutes, this calculation will not work when the interval includes the time changes due to Day Light Saving Time, British Summer Time, or other adjustment to local time to adjust for the hours of daylight. If the date is included JavaScript will automatically adjust for the 1 hour change in the local time.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now