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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top