lubridate (version 0.2.1)

year: Get/set years component of a date-time.

Description

Get/set years component of a date-time.

Usage

year(x)

Arguments

x
a date-time object

Value

  • the years element of x as a decimal number

Details

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

year does not yet support years before 0 C.E.

Examples

Run this code
x <- now()
year(x) 
year(x) <- 2001  
year(x) > 1995

Run the code above in your browser using DataLab