time

1日後や1ヶ月前の日付を得る

require 'date' def time_to_date( t) DateTime.new( t.year, t.mon, t.day, t.hour, t.min, t.sec) end def date_to_time( d) Time.mktime( d.year, d.mon, d.day, d.hour, d.min, d.sec) end t1 = Time.now # 基準日 d1 = time_to_date( t1) p (d1 + 1).st…

今日の日付を得る

p Time.now p (Time.now+1*60*60*24) # 1日後 p Time.now.strftime("%Y/%m/%d %H:%M:%S") strftimeの書式はstrftime(3)を参照する.直接,数値を取得するには: p Time.now.day p Time.now.min