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

month(x, label = FALSE, abbr = TRUE, locale = Sys.getlocale("LC_TIME"))

month(x) <- value

Arguments

x

a date-time object

label

logical. TRUE will display the month as a character string such as "January." FALSE will display the month as a number.

abbr

logical. FALSE will display the month as a character string label, such as "January". TRUE will display an abbreviated version of the label, such as "Jan". abbr is disregarded if label = FALSE.

locale

for month, locale to use for month names. Default to current locale.

value

a numeric object

Value

the months element of x as a number (1-12) or character string. 1 = January.

Examples

x <- ymd("2012-03-26") month(x)
#> [1] 3
month(x) <- 1 month(x) <- 13 month(x) > 3
#> [1] FALSE
month(ymd(080101))
#> [1] 1
month(ymd(080101), label = TRUE)
#> [1] jan #> 12 Levels: jan < feb < mrt < apr < mei < jun < jul < aug < sep < ... < dec
month(ymd(080101), label = TRUE, abbr = FALSE)
#> [1] januari #> 12 Levels: januari < februari < maart < april < mei < juni < ... < december
month(ymd(080101) + months(0:11), label = TRUE)
#> [1] jan feb mrt apr mei jun jul aug sep okt nov dec #> 12 Levels: jan < feb < mrt < apr < mei < jun < jul < aug < sep < ... < dec