**Inside Macintosh:****AppleScript Language Guide**/**Part 2 - AppleScript Language Reference****Chapter 6 - Expressions**/**Operations**

## Date-Time Arithmetic

AppleScript supports these operations with the + and - operators on date and time difference values:

date + timeDifference --result: date date - date --result: timeDifference date - timeDifference --result: datewheredateis a date value andtimeDifferenceis an integer value specifying a time difference in seconds.To simplify the notation of time differences, you can also use one or more of these constants:

minutes 60 hours 60 * minutes days 24 * hours weeks 7 * days Here's an example:

date "Apr 15, 1992" + 4 * days + 3 * hours + 2 * minutesIt is often useful to be able to specify a time difference between two dates;

for example:

set timeInvestment to current date - "May 16, 1992"After running this script, the value of the`timeInvestment`

variable is an integer that specifies the number of seconds between the two dates. If you then add this time difference to the starting date (May 16, 1992), AppleScript returns a date value equal to the current date when the`timeInvestment`

variable was set.To express a time difference in more convenient form, divide the number of seconds by the appropriate constant:

31449600 / years --result: 1 151200 / days --result: 1.75To get an integral number of hours, days, and so on, use the`div`

operator:

151200 div days --result: 1To get the difference, in seconds, between the current time and Greenwich mean time, use the scripting addition command Time to GMT. For example, if you are in Cupertino, California, and your computer is set to Pacific Standard Time, Time to GMT produces this result:

time to GMT --result: -28800For more information about the Time to GMT command, see theAppleScript Scripting Additions Guide.

13 JUL 1996