http://api.rubyonrails.org/classes/Time.html#method-i-advance documents a method advance()
to add to the current time. Is there an opposite, 'go_back()
method?
The now() is an inbuilt method in Ruby returns the current time. Syntax: time.now() Parameters: The function accepts no parameter. Return Value: It returns the current time.
You can get the current date using Date. today .
Ruby has three components for representing Date and Time class. Date – Date class manages the dates, day, month, year. Time – It manages the seconds, minute, hours. DateTime – It includes the above two classes.
I don't think there is but there's nothing to stop you using negative values in advance
.
Time.now.advance(:days => - 1, :hours => -1)
You can use something like the following example
Time.now - 3.days
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With