redirect_to :future #思维驱动 » Blog Archive » Rails time_zone时间比较.

Rails time_zone时间比较.

In config/environment.rb:
config.time_zone = ‘Beijing’

Rails Will store time in UTC in the database.

in action:
@actions = Action.all(:conditions=>[”status=’C0A’ and completed_at>? “,DateTime::now.beginning_of_day])
DateTime::now valued in UTC+8(Bejing)

should replace to :
@actions = Action.all(:conditions=>[”status=’C0A’ and completed_at>? “,DateTime::now.utc.beginning_of_day])

看完啦?再看看我们最近的10条记录对您是否有用呢?

要不,再找找其它内容:




或者给我们留下些意见、建议,这将给我们莫大的鼓励,促使我们做得更好。