code_junkie

Ruby on Rails and Active Record standalone scripts disagree on database values for :timestamps

Nov 12th, 2011
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. record = Record.find(:first)
  2. record.the_time = Time.now()
  3.  
  4. <%= h record.the_time %>
  5.  
  6. record = Record.find(:first)
  7. puts record.the_time
  8.  
  9. Wed Nov 26 00:40:00 (-0800) 2008
  10.  
  11. # Make Time.zone default to the specified zone, and make Active Record store time values
  12. # in the database in UTC, and return them converted to the specified local zone.
  13. # Run "rake -D time" for a list of tasks for finding time zone names. Uncomment to use default local time.
  14. config.time_zone = 'UTC'
  15.  
  16. require 'active_support/core_ext/date/conversions'
  17. record.the_time.utc.to_s(:db)
Add Comment
Please, Sign In to add comment