Computing Time DifferencesAuthor: Carl Sassenrath This example shows how to easily calculate the difference between two dates or times. To compute the number of days between two dates, just subtract them. To get a positive number, put the more recent date first:
Using this, you can do things like show how many days old you are:
Or even how old a file is:
Sometimes you want to show the difference as a time (hours) not as days. In newer versions of REBOL the DIFFERENCE function will return the time difference between two datetime values:
Note that too large a time span may overflow the number of hours that can be held by the time datatype. Also take note that the DIFFERENCE function accounts for timezone variations:
