我在铁路上工作,我试图弄清楚如何设置时区,所以Time.now
给了我
Mon, 03 Jun 2019 19:08:13 CDT -05:00
Try this:
# application.rb
class Application < Rails::Application
config.time_zone = 'Eastern Time (US & Canada)'
end
Time.zone # => #<ActiveSupport::TimeZone:0x514834...>
Time.zone.name # => "Eastern Time (US & Canada)"
Time.zone.now # => Sun, 18 May 2008 14:30:44 EDT -04:00
Source: https://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.