I have a problem when showing a datetime object from the database. The time is correctly set in when storing the object, but when it is fetched from db and shown to user it is shown in UTC
environment.rb
config.time_zone = 'Copenhagen'
This is what is saved using Time.now or Time.zone.now
2010-07-08 13:59:50 +0200
This is what is shown to the user when using the html helper <%=h ff.date_registered %>
2010-07-08 11:59:50 UTC
Try Time.current. Time.now is returned in UTC -5 always. ActiveRecord instructs Time.current based on your config.time_zone. See this github issue for more information, https://github.com/rails/rails/issues/3128#issuecomment-2195751
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