Ruby | Time mon() function
The mon() is an inbuilt method in Ruby returns the month of the year for time.
Syntax: time.mon()
Parameters: The function accepts no parameter
Return Value: It returns the month of the year for time.
Example 1:
# Ruby code for mon() method # Include Time require 'time' # Declaring time a = Time.new(2000, 12, 23) # Prints the month of the year for the time puts a.mon() |
chevron_right
filter_none
Output:
12
Example 2:
# Ruby code for mon() method # Include Time require 'time' # Declaring time a = Time.now() # Prints the month of the year for the time puts a.mon() |
chevron_right
filter_none
Output:
8
Recommended Posts:
- Ruby | Time utc function
- Ruby | Time - function
- Ruby | Time + function
- Ruby | Time sec() function
- Ruby | Time dst?() function
- Ruby | Time day() function
- Ruby | Time eql?() function
- Ruby | Time now() function
- Ruby | Time min function
- Ruby | Time gmt? function
- Ruby | Time utc? function
- Ruby | Time friday? function
- Ruby | Time asctime() function
- Ruby | Time hash function
- Ruby | Time utc_offset function
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.



