This help topic is for R version 1.5.0. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/base/html/round.POSIXt.html
round.POSIXt {base}R Documentation

Round / Truncate Data-Time Objects

Description

Round or truncate date-time objects.

Usage

## S3 method for class 'POSIXt'
round(x, units=c("secs", "mins", "hours", "days"))
trunc.POSIXt(x, units=c("secs", "mins", "hours", "days"))

Arguments

x

an object inheriting from "POSIXt".

units

one of the units listed. Can be abbreviated.

Details

The time is rounded or truncated to the second, minute, hour or day. Timezones are only relevant to days, when midnight in the current timezone is used.

Value

An object of class "POSIXlt".

Note

trunc is not generic, so trunc.POSIXt has to be called explicitly.

See Also

DateTimeClasses

Examples

round(.leap.seconds + 1000, "hour")
trunc.POSIXt(Sys.time(), "day")

[Package base version 1.5.0 ]