You can use the Ruby monkey patch, as Nikolaus showed you, or you can use the TimeCop gem. It was designed to make writing tests easier, but you can also use it in your regular code.
# Set the time where you want to go. t = Time.local(2008, 9, 1, 10, 5, 0) Timecop.freeze(t) do
This is a great but simple piece of code. Try it, it will save you some headaches when you both have a date and time.
Link: https://rubygems.org/gems/timecop
Ariejan
source share