【问题标题】:Where does Rails get the timezone before converting to the UTC 0 timezone?在转换为 UTC 0 时区之前,Rails 在哪里获取时区?
【发布时间】:2018-02-28 23:27:45
【问题描述】:

现在是美国东部标准时间下午 6:25。 Active Record 会将该时间转换为 23:45 UTC 0。Rails 是如何知道该转换基于哪个时区的?是从浏览器区域设置还是应用服务器获取?

谢谢。

【问题讨论】:

    标签: ruby-on-rails activerecord timezone


    【解决方案1】:
    # application.rb:
    class Application < Rails::Application
       config.time_zone = 'Eastern Time (US & Canada)'
    end
    #model.rb
    t = (Time.now-6.hours).beginning_of_day 
     #Use this method in your model with create and use the different 
     #timing 
     #and it look like -5 not -6 as mine :D
    

    【讨论】:

      猜你喜欢
      • 2019-11-23
      • 1970-01-01
      • 2011-09-16
      • 2020-03-21
      • 1970-01-01
      • 2022-01-09
      • 2011-02-11
      • 2012-11-17
      • 2016-10-10
      相关资源
      最近更新 更多