Getting components

  • year(), month(), hour(), minute(), second()
  • day() == mday(), yday() (day of year), wday() (day of week)
datetime <- ymd_hms("2024-03-08 19:32:28")
year(datetime)
## [1] 2024
mday(datetime)
## [1] 8
yday(datetime)
## [1] 68
wday(datetime, label = TRUE)
## [1] Fri
## Levels: Sun < Mon < Tue < Wed < Thu < Fri < Sat