How to ignore DayLight saving time #7

Closed
grepruby opened this Issue Oct 29, 2013 · 1 comment

Comments

Projects
None yet
2 participants
@grepruby

Sorry to create it as a issue but I don't find any good way reach you.

Is there any way I can turn off DayLight saving in my rails app?

Thanks

@philr

This comment has been minimized.

Show comment
Hide comment
@philr

philr Oct 29, 2013

Member

This question is really about how to configure and use Ruby on Rails. Internally, Rails uses TZInfo to perform conversions between time zones. However, the specifics of how times are displayed and stored are entirely down to Rails.

There are two configuration options that control how Rails uses time zones:

  • config.time_zone allows you to set the default time zone used for displaying and parsing times (run rake time:zones:all to see the list of available Rails time zones).
  • config.active_record.default_timezone determines whether to use local time (:local) or UTC (:utc) when storing dates and times in the database.

It's not clear to me exactly what you mean by turning off daylight savings. You'll probably want to set config.time_zone to an appropriate local time zone and then set config.active_record.default_timezone according to what you want to be stored in the database. This will then cause times to be displayed in the local time zone.

Member

philr commented Oct 29, 2013

This question is really about how to configure and use Ruby on Rails. Internally, Rails uses TZInfo to perform conversions between time zones. However, the specifics of how times are displayed and stored are entirely down to Rails.

There are two configuration options that control how Rails uses time zones:

  • config.time_zone allows you to set the default time zone used for displaying and parsing times (run rake time:zones:all to see the list of available Rails time zones).
  • config.active_record.default_timezone determines whether to use local time (:local) or UTC (:utc) when storing dates and times in the database.

It's not clear to me exactly what you mean by turning off daylight savings. You'll probably want to set config.time_zone to an appropriate local time zone and then set config.active_record.default_timezone according to what you want to be stored in the database. This will then cause times to be displayed in the local time zone.

@philr philr closed this Oct 29, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment