Hello i am working on a rails project. i want the time with specific zone, i know i can use Time.zone.now
but i want to first set the zone and then want to get the time based on the zone. is there any way so that i can override the Time.now
method with Time.zone.now
after setting the zone.
I have tried to create a before action in application_controller.rb and then define the zone, but whenever i am trying to access Time.now its always returns the time without time zone. please help me. Thanx in advance.
application_controller.rb
def set_current_time_zone
Time.zone = current_user.time_zone unless current_user.blank?
end