I am using ActiveRecord in a non-rails project. In rails I can do:
config.time_zone = 'Eastern Time (US & Canada)'
config.active_record.default_timezone = 'Eastern Time (US & Canada)'
But if I am not using rails, how can I set the timezone?
One of the primary aspects of ActiveRecord is that there is very little to no configuration needed. It follow convention over configuration. ActiveRecord is commonly used with the Ruby-on-Rails framework but you can use it with Sinatra or without any web framework if desired.
Ruby | Time zone() functionTime#zone() : zone() is a Time class method which returns the name of the time zone used for time like “UTC”, “GMT”.
ActiveRecord::Base.default_timezone = 'Eastern Time (US & Canada)'
ActiveRecord::Base.default_timezone = :local
also works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With