as_date {lubridate} | R Documentation |
A drop in replacement for base as.Date
with two two
differences. First, it ignores timezone attribute resulting in a more
intuitive conversion (see examples). Second, it does not require origin
argument which defaults to 1970-01-01.
as_date(x, ...) ## S4 method for signature 'POSIXt' as_date(x, tz = NULL) ## S4 method for signature 'numeric' as_date(x, origin = lubridate::origin)
x |
a vector of |
... |
further arguments to be passed to specific methods (see above). |
tz |
a time zone name (default: time zone of the POSIXt object
|
origin |
a Date object, or something which can be coerced by
|
a vector of Date
objects corresponding to x
.
dt_utc <- ymd_hms("2010-08-03 00:50:50") dt_europe <- ymd_hms("2010-08-03 00:50:50", tz="Europe/London") c(as_date(dt_utc), as.Date(dt_utc)) ## [1] "2010-08-03" "2010-08-03" c(as_date(dt_europe), as.Date(dt_europe)) ## [1] "2010-08-03" "2010-08-02" ## need not suply origin as_date(10) ## [1] "1970-01-11"