title: Ruby on Rails and Active Record standalone scripts disagree on database values for :timestamps
body: <p>I posted a question earlier today when I'd not zeroed in quite so far on the problem.  I'll be able to be more concise here.</p>
  
  <p>I'm running RoR 2.1.2, on Windows, with MySQL.  The SQL server's native time zone is UTC.  My local timezone is Pacific (-0800)</p>
  
  <p>I have a model with a :timestamp type column which I can do things like this with:</p>
  
  <pre><code>record = Record.find(:first)
  record.the_time = Time.now()
  </code></pre>
  
  <p>When I do a "select * from records" in the database, the time shown is eight hours in advance of my local time, which is correct, given that the DB is on UTC.  (I have verified that it is 'thinking in utc' with a simple 'select now()' and 'select utc_timestamp()')</p>
  
  <p>This is where the trouble begins.  If I display the time in a view:</p>
  
  <pre><code>&lt;%= h record.the_time %&gt;
  </code></pre>
  
  <p>...then I get back the correct time, displayed in UTC format.  If I wrote to the database at 16:40:00 local time, the database showed 00:40:00.</p>
  
  <p>HOWEVER, if I am running a standalone script:</p>
  
  <pre><code>record = Record.find(:first)
  puts record.the_time
  </code></pre>
  
  <p>...then I get back the UTC time that I stored in the database (00:40:00,) but with the local timezone:</p>
  
  <pre><code>Wed Nov 26 00:40:00 (-0800) 2008
  </code></pre>
  
  <p>...an eight-hour time warp.  Why is it that storing the time translates it correctly, but retrieving it does not?  If I compare a stored time from the recent past in the DB and compare it to the current time, the current time is less - telling me this isn't just a string conversion issue.  </p>
  
  <p>Any ideas?</p>