Rails timezone and Daylight saving time

前端 未结 2 1129
野性不改
野性不改 2021-01-07 22:17

for a while I´m trying to understand how this timezone times will work, and I had a question:

Today in my country, we are in Daylight saving time (GMT-2). So the u

2条回答
  •  再見小時候
    2021-01-07 22:41

    7 months after you asked, but perhaps skip_time_zone_conversion_for_attributes= will help - it tells AR not to convert timezones on storage or retrieval. See [ActiveRecord Timestamp] (http://api.rubyonrails.org/classes/ActiveRecord/Timestamp.html) which shows the example:

    class Topic < ActiveRecord::Base
      self.skip_time_zone_conversion_for_attributes = [:written_on]
    end
    

    --Kip

提交回复
热议问题