S
S
Shaks2015-03-04 17:21:20
Ruby on Rails
Shaks, 2015-03-04 17:21:20

Why is there a shift of 3 hours if I set created_at manually?

2.2.0 :001 > toster = Toster.new
 => #<Toster id: nil, question: nil, created_at: nil, updated_at: nil> 
2.2.0 :002 > toster.created_at = Time.new(2015,10,31)
 => 2015-10-31 00:00:00 +0300 
2.2.0 :003 > toster
 => #<Toster id: nil, question: nil, created_at: "2015-10-30 21:00:00", updated_at: nil> 
2.2.0 :004 >

Pay attention, I put the date one, and get another one at the output) Why is this happening? And is it curable?
# config/application.rb
config.time_zone = 'Europe/Moscow'
config.active_record.default_timezone = :local

sec .. some kind of crap.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MiiNiPaa, 2015-03-04
@shaks

EMNIP without specifying the time zone, it is taken from the system settings. Apparently Toster converts the time to GMT.
Looks like this is a bug:
Demonstration of the bug is the same as the OP's problem: wrong time in created_at
Same bug with developers' comment that it won't be fixed.

O
OnYourLips, 2015-03-04
@OnYourLips

It's the same date, just displayed in different timezones.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question