红宝石 |时间 mday()函数
mday()是 Ruby 中的一个内置方法,它返回月份中的日期作为时间。
Syntax: time.mday()
Parameters: The function accepts no parameter
Return Value: It returns the day of the month for time.
示例 1 :
# Ruby code for mday() method
# Include Time
require 'time'
# Declaring time
a = Time.new(2000, 12, 23)
# Prints the day of the month for the time
puts a.mday()
输出:
23
示例 2 :
# Ruby code for mday() method
# Include Time
require 'time'
# Declaring time
a = Time.now()
# Prints the day of the month for the time
puts a.mday()
输出:
27