Extract Parts of a POSIXt or Date Object
Extract the weekday, month or quarter, or the Julian time (days since some origin). These are generic functions: the methods for the internal date-time classes are documented here.
weekdays(x, abbreviate) "weekdays"(x, abbreviate = FALSE) "weekdays"(x, abbreviate = FALSE)months(x, abbreviate) "months"(x, abbreviate = FALSE) "months"(x, abbreviate = FALSE)quarters(x, abbreviate) "quarters"(x, ...) "quarters"(x, ...)julian(x, ...) "julian"(x, origin = as.POSIXct("1970-01-01", tz = "GMT"), ...) "julian"(x, origin = as.Date("1970-01-01"), ...)
- an object inheriting from class
- logical. Should the names be abbreviated?
- an length-one object inheriting from class
- arguments for other methods.
monthsreturn a character vector of names in the locale in use.
quartersreturns a character vector of
julianreturns the number of days (possibly fractional) since the origin, with the origin as a
"origin"attribute. All time calculations in R are done ignoring leap-seconds.
Other components such as the day of the month or the year are
very easy to compute: just use
as.POSIXlt and extract
the relevant component. Alternatively (especially if the components
are desired as character strings), use