date: Get/set date component of a date-time

Description Usage Arguments Details Value Examples

View source: R/accessors-date.R

Description

Date-time must be a POSIXct, POSIXlt, Date, chron, yearmon, yearqtr, zoo, zooreg, timeDate, xts, its, ti, jul, timeSeries, and fts objects.

Usage

1
2
3
date(x)

date(x) <- value

Arguments

x

a date-time object

value

an object for which the date() function is defined

Details

date() does not yet support years before 0 C.E. Also date() is not defined for Period objects.

Value

the date of x as a Date

Examples

1
2
3
4
5
6
x <- ymd_hms("2012-03-26 23:12:13", tz = "America/New_York")
date(x)
as.Date(x) # by default as.Date assumes you want to know the date in UTC
as.Date(x, tz = "America/New_York")
date(x) <- as.Date("2000-01-02")
x

lubridate documentation built on Nov. 17, 2017, 6:56 a.m.