一個方法如何使用當前的Time.zone並將其放入可供ActiveSupport::TimeZone[some_zone].parse()
使用的格式?在Rails中,如何獲取可用於ActiveSupport :: TimeZone [zone] .parse()的格式的當前時區(Time.zone)?
這似乎很奇怪,Time.zone.to_s返回不能ActiveSupport::TimeZone[zone].parse()
Time.zone.to_s
回報"(GMT-08:00) Pacific Time (US & Canada)"
但ActiveSupport::TimeZone["(GMT-08:00) Pacific Time (US & Canada)"]
使用的字符串是nil
。
ActiveSupport::TimeZone["(GMT-08:00) Pacific Time (US & Canada)"]
=> nil
ActiveSupport::TimeZone["Pacific Time (US & Canada)"]
=> (GMT-08:00) Pacific Time (US & Canada)
真棒謝謝你......看着文檔,從來沒有看到它。很想知道,如何找到這種東西? – jpwynn
我更新了我的答案,以解釋我可能會如何找到它。 – deefour