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