質問

Using Rails 2.3, when I run ActiveSupport::TimeZone.us_zones, I get the following:

....
* UTC -08:00 *
Pacific Time (US & Canada)
....

Now, since DST is in effect right now, the UTC offset should have been -07:00 !

Anyone know how to get the correct Time zone offsets in Rails 2.3 ?

役に立ちましたか?

解決

You can use the UTC offset of the current time in that time zone:

zone = ActiveSupport::TimeZone['Eastern Time (US & Canada)']
zone.now.utc_offset
=> -14400

zone.utc_offset
=> -18000
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top