print()method calls these “time differences”.
time1 - time2
difftime(time1, time2, tz, units = c("auto", "secs", "mins", "hours", "days", "weeks"))
as.difftime(tim, format = "%X", units = "auto")
# S3 method for difftime format(x, ...) # S3 method for difftime units(x) # S3 method for difftime units(x) <- value # S3 method for difftime as.double(x, units = "auto", ...)
## Group methods, notably for round(), signif(), floor(), ## ceiling(), trunc(), abs(); called directly, *not* as Math(): # S3 method for difftime Math(x, …)
units, except that abbreviations are not allowed.
strptime. The default is a locale-specific time format.
difftimecalculates a difference of two date/time objects and returns an object of class
"difftime"with an attribute indicating the units. The
Mathgroup method provides
signmethods for objects of this class, and there are methods for the group-generic (see
Ops) logical and arithmetic operations. If
units = "auto", a suitable set of units is chosen, the largest possible (excluding
"weeks") in which all the absolute differences are greater than one. Subtraction of date-time objects gives an object of this class, by calling
units = "auto". Alternatively,
as.difftime()works on character-coded or numeric time intervals; in the latter case, units must be specified, and
formathas no effect. Limited arithmetic is available on
"difftime"objects: they can be added or subtracted, and multiplied or divided by a numeric vector. In addition, adding or subtracting a numeric vector by a
"difftime"object implicitly converts the numeric vector to a
"difftime"object with the same units as the
"difftime"object. There are methods for
Summarygroup generic), and
diff.defaultbuilding on the
"difftime"method for arithmetic, notably
-. The units of a
"difftime"object can be extracted by the
unitsfunction, which also has a replacement form. If the units are changed, the numerical value is scaled accordingly. The replacement version keeps attributes such as names and dimensions. Note that
units = "days"means a period of 24 hours, hence takes no account of Daylight Savings Time. Differences in objects of class
"Date"are computed as if in the UTC time zone. The
as.doublemethod returns the numeric value expressed in the specified units. Using
units = "auto"means the units of the object. The
formatmethod simply formats the numeric value and appends the units as a text string.