2013-07-15 36 views
4

我在非導軌項目中使用ActiveRecord。我可以這樣做:沒有導軌的ActiveRecord時區

config.time_zone = 'Eastern Time (US & Canada)' 
config.active_record.default_timezone = 'Eastern Time (US & Canada)' 

但是,如果我不使用rails,我該如何設置時區?

+1

[這有什麼幫助嗎?](http://www.gittr.com/index.php/archive/activerecord-timezones-without-rails/) –

回答

2
ActiveRecord::Base.default_timezone = 'Eastern Time (US & Canada)' 
2
ActiveRecord::Base.default_timezone = :local 

也爲我工作。