Open In App

Ruby | Time mon() function

Last Updated : 12 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report
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: CPP
# 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()
Output:
12
Example 2: CPP
# 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()
Output:
8

Similar Reads