Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set mysql2 timezone option to remove query warning

Tags:

ruby

mysql2

I always get warning when use mysql2 do query

/usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/active_record/connection_adapters/mysql2_adapter.rb:463: warning: :database_timezone option must be :utc or :local - defaulting to :local

I did see a option for Timezones

Mysql2 now supports two timezone options:

  :database_timezone - this is the timezone Mysql2 will assume fields are already stored as, and will use this when creating the initial Time objects in ruby
  :application_timezone - this is the timezone Mysql2 will convert to before finally handing back to the caller

did any one know, how to usage, and where to set this option?

Thanks.

like image 924
Hunter Avatar asked Dec 24 '10 01:12

Hunter


1 Answers

This is how I had fixed it:

config.active_record.default_timezone = :utc
like image 95
Zabba Avatar answered Sep 20 '22 13:09

Zabba