Get date/time parts from date and time objects

get* functions provide an *experimental* approach for extracting the date/time parts from objects of a date/time class. They are designed to be intiutive and thus lowering the learning curve for work with date and time classes in R.

Keywords
misc, manip
Usage
getYear(x, format, …)
getMonth(x, format, …)
getDay(x, format, …)
getHour(x, format, …)
getMin(x, format, …)
getSec(x, format, …)
Arguments
x

generic, date/time object

format

character, format

arguments pased to other methods

Value

Character

See Also

Date, DateTimeClasses, strptime

Aliases
  • getDateTimeParts
  • getYear
  • getYear.default
  • getYear.Date
  • getYear.POSIXct
  • getYear.POSIXlt
  • getMonth
  • getMonth.default
  • getMonth.Date
  • getMonth.POSIXct
  • getMonth.POSIXlt
  • getDay
  • getDay.default
  • getDay.Date
  • getDay.POSIXct
  • getDay.POSIXlt
  • getHour
  • getHour.default
  • getMin
  • getMin.default
  • getSec
  • getSec.default
Examples

## --- Date class ---

tmp <- Sys.Date()
tmp

getYear(tmp)
getMonth(tmp)
getDay(tmp)

## --- POSIXct class ---

tmp <- as.POSIXct(tmp)

getYear(tmp)
getMonth(tmp)
getDay(tmp)

## --- POSIXlt class ---

tmp <- as.POSIXlt(tmp)

getYear(tmp)
getMonth(tmp)
getDay(tmp)

Documentation reproduced from package gdata, version 2.18.0, License: GPL-2

Community examples

Looks like there are no examples yet.