change(options)
Instance Public methods
Returns a new Time where one or more of the
elements have been changed according to the options
parameter.
The time options (:hour
, :min
, :sec
,
:usec
) reset cascadingly, so if only the hour is passed, then
minute, sec, and usec is set to 0. If the hour and minute is passed, then
sec and usec is set to 0. The options
parameter takes a hash
with any of these keys: :year
, :month
,
:day
, :hour
, :min
,
:sec
, :usec
.
Time.new(2012, 8, 29, 22, 35, 0).change(day: 1) # => Time.new(2012, 8, 1, 22, 35, 0) Time.new(2012, 8, 29, 22, 35, 0).change(year: 1981, day: 1) # => Time.new(1981, 8, 1, 22, 35, 0) Time.new(2012, 8, 29, 22, 35, 0).change(year: 1981, hour: 0) # => Time.new(1981, 8, 29, 0, 0, 0)
Please login to continue.