Frage

In order to get the beginning of today in the current time zone, I had the following code:

Time.zone.today.to_time_in_current_zone

However, upgrading to Rails 4.1 caused an error as the to_time_in_current_zone method was removed. What should I use as an alternative? Time.zone.today.to_time gives me the beginning of the day in UTC time zone.

War es hilfreich?

Lösung

You should use in_time_zone instead.

Time.zone.today.in_time_zone

Till 4.0.2 to_time_in_current_zone was supported. See this link for more info.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top