PRODOK Engineering


28 January 2007

One-liner of the Week: Simple Time Calculation

by Max Wyss

Resently a member of the PlanetPDF forum asked about a way to calculate the time difference between two times indicated in a drop down menu. The times in the drop down menu represent quarter hours (0:00, 0:15, 0:30, 0:45, 1:00, etc.).

(Acrobat) JavaScript provides some extensive time (and date) related functionality in the Date object of the Core. However, using this object is sometimes a bit awkward, and requires some scripting: First, the time strings must be converted to a valid date object. Then, the subtraction is executed. And finally, the result is converted to the desired output string.

Syndicate content