Get date/time parts from date and time objects

Share:

Description

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.

Usage

1
2
3
4
5
6

Arguments

x

generic, date/time object

format

character, format

...

arguments pased to other methods

Value

Character

Author(s)

Gregor Gorjanc

See Also

Date, DateTimeClasses, strptime

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## --- 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)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.