The problem is another point. I wrote a method that corrects the time zone offset, and the method changes the time zone of Rails. Here is the code.
class WeeklyEvent < ActiveRecord::Base def adjust_time_zone_offset Time.zone = timezone # => This is the problem. Rails Time.zone changes to timezone. time_zone_offset = Time.zone.utc_offset # => 32400 JST offset 9 hours in seconds. self.start_date_time = (start_date_time - time_zone_offset).in_time_zone('UTC') end end japanese_event = WeeklyEvent.find(1) p japanese_event.start_date_time #=> Sun, 01 Jan 2012 09:00:00 JST +09:00
source share