title: Time.zone & in_time_zone display wrong time in views
body: <p>So I'm getting some inconsistent results from dates in my view when I've set the Time.zone. I'm hoping someone can tell me what is going on. I've got ruby on rails app running on an ubuntu server 12.04</p>
  
  <p>In my application controller I have a before_filter setting the Time.zone from the current_user's company's time_zone record.</p>
  
  <pre><code>before_filter :set_user_time_zone
  
  private
  
  def set_user_time_zone
    Time.zone = current_user.company.time_zone if user_signed_in?
  end
  </code></pre>
  
  <p>The user I'm testing with is in the "Central Time (US &amp; Canada)"</p>
  
  <p>the raw database record is 2012-08-13 20:10:54</p>
  
  <p>In my view I'm using the following code to format the date:</p>
  
  <pre><code>servicedata.service_last_run_time.strftime('%b %e, %Y %l:%M%P')
  </code></pre>
  
  <p>I would expect to return "Aug 13, 2012 8:10pm" which would be the above record in the "Central Time (US &amp; Canada)" however I get "Aug 13, 2012 9:10am"</p>
  
  <p>I tested the same code in rails console and it works fine. I'm unsure of why its not working.</p>
  
  <p>Before I found the idea for the before_filter I was simply chaining "in_time_zone" in all of my views but getting the same results. Example</p>
  
  <pre><code>servicedata.service_last_run_time.in_time_zone(current_user.company.time_zone).strftime('%b %e, %Y %l:%M%P') 
  </code></pre>
  
  <p>Again both Time.zone or manually chaining in_time_zone onto a date object worked fine in rails console but in the views return a horrible wrong time.</p>
  
  <p>I tested the server is time to ensure they were unchanged UTC from the following:</p>
  
  <pre><code>Rails Console : 2012-08-14 02:06:29 +0000
  Ubuntu Shell: Tue Aug 14 02:06:38 UTC 2012
  </code></pre>
  
  <p>I have no clue what I'm missing here.</p>