When I check time on Rails in my production server
$ rails console production
$ Time.now # good time
On Mysql production
mysql > select now(); # good time
but after I'm saving any record to database, "created_at" and "updated_at" fields are -2 hours from current time. What is wrong here?
I have restarted mysql, nginx after time changes. What can I do next? Is it Rails of Mysql define time for these fields?
That's because the timezone your data is saved in the db is UTC
. If you want to change it to local, set in application.rb
:
config.active_record.default_timezone = :local
and you should declare explicitly your timezone if you haven't yet:
config.time_zone = 'Vilnius'
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