Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
active record timezone without rails


Francis.J 2014-9-4 11:30:02

zone_default = Time.find_zone!("Asia/Shanghai")
Time.zone_default = zone_default

ActiveRecord::Base.time_zone_aware_attributes = true
ActiveRecord::Base.default_timezone = :utc

Francis.J 2014-9-4 11:30:04 你看看

俞飞鹏 2014-9-4 11:30:23 好

Francis.J 2014-9-4 11:31:28 api 保存的时候 转成 utc 取出来的时候 再 time_zone 11:32:21 Francis.J 2014-9-4 11:32:21 这里 才是关键 xd

Francis.J 2014-9-4 11:33:22 我们 api 里面 默认不是 true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment