0
嗨Date对象所以在红宝石我尝试做一个程序,需要一个参数,并且正是“X”个月前返回的日期,我可以说这一年月份和日期,但无法显示小时分钟和秒钟。有什么建议么?由于做一个Time.local对象,它包含在Ruby中
require "Time"
require "Date"
class "Time"
def months_ago(n)
y = Time.now.year
d = Time.now.day
mn = Time.now.month
s = Time.now.sec
h = Time.now.hour
m = Date.civil(y, mn, d)
m <<(n)
end
end
a = Time.new.months_ago(4)
puts a