Determine the Month on a Specific Date in R Programming – months() Function

months() function in R Language is used to determine the month on a specific date passed to it as argument.

Syntax: months(date, abbreviate)

Parameters:
date: Date to be checked
abbreviate: Boolean value to abbreviate month

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to find the month 
# on a specific date
  
# Specifying the date
date <- as.POSIXlt("2020-06-23")
date
  
# Calling months() function
months(date)

chevron_right


Output:

[1] "2020-06-23 UTC"
[1] "June"

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to find the month 
# on a specific date
  
# Specifying the date
date <- as.POSIXlt("1994-01-17")
date
  
# Calling months() function
months(date, abbreviate = TRUE)

chevron_right


Output:

[1] "1994-01-17 UTC"
[1] "Jan"
My Personal Notes arrow_drop_up

Recommended Posts:


Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.