『实际时间为 北京时间 14 点左右』
2.3.0 :001 > ming = User.create(name:"小明",email:"[email protected]")
(0.1ms) begin transaction
SQL (1.0ms) INSERT INTO "users" ("name", "email", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["name", "小明"], ["email", "[email protected]"], ["created_at", "2016-01-15 06:04:44.095125"], ["updated_at", "2016-01-15 06:04:44.095125"]]
(0.8ms) commit transaction
=> #<User id: 3, name: "小明", email: "[email protected]", created_at: "2016-01-15 06:04:44", updated_at: "2016-01-15 06:04:44">
# 时区
config.time_zone = "Beijing"
config.active_record.default_timezone = :local
2.3.0 :002 > exit
Cbd-MacBook-Pro:sample cbd$ rails c
Loading development environment (Rails 4.2.2)
2.3.0 :001 > gang = User.create(name:"小刚",email:"[email protected]")
(0.2ms) begin transaction
SQL (0.3ms) INSERT INTO "users" ("name", "email", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["name", "小刚"], ["email", "[email protected]"], ["created_at", "2016-01-15 14:05:47.858347"], ["updated_at", "2016-01-15 14:05:47.858347"]]
(8.8ms) commit transaction
=> #<User id: 4, name: "小刚", email: "[email protected]", created_at: "2016-01-15 06:05:47", updated_at: "2016-01-15 06:05:47">