I have the following Mongoid model...
class Eve开发者_运维百科nt
  include Mongoid::Document
  include Mongoid::Timestamps::Created
  include Mongoid::Timestamps::Updated
  include Mongoid::MultiParameterAttributes
  key :name
  field :name
  field :begins_at, type: Time
  field :ends_at, type: Time
  belongs_to :city
  attr_accessor :time_zone
end
I'd like to be able to have a per-event TimeZone. Obviously due to the complications of time zones the best way to handle this is to store times in UTC when going to the DB and convert back to the event's time zone on the way out of the DB.
I know ActiveRecord has support for this and I was wondering if Mongoid has any kind of native support for this.
Store as: timestamp and when query Format to timezone
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论