title: How set my timezone correctly to save a record correctly?
body: <p>In my rails application I'm getting data and saving it by its date for all the records that has the today's date for a later call.</p>
  
  <p>The problem is the data comes in this format <strong>"8:05 PM ET"</strong> </p>
  
  <p>When I parse it to get it in the date format I get this:</p>
  
  <pre><code>"Mon, 24 Aug 2015 20:05:00 EDT -04:00"
  </code></pre>
  
  <p>,which is the right date. The thing is when I save it in the database is saved as </p>
  
  <pre><code>"2015-08-25 00:05:00 UTC"
  </code></pre>
  
  <p>When I request to the db give me all the data from today it doesn't retrieve this record because the date says that record is 25 "tomorrow"** and not **24 "today". </p>
  
  <p>How can I save that record in my database as 
  <strong>today "24"</strong> and not as
  <strong>tomorrow "25"</strong>?</p>
  
  <p>My configuration:</p>
  
  <p>application.rb </p>
  
  <pre><code>class Application &lt; Rails::Application
      Dir["#{Rails.root}/lib/**/**/*.rb"].each { |f| require f }
      config.time_zone = 'Eastern Time (US &amp; Canada)'.freeze
      config.active_record.default_timezone = :local
      config.active_record.raise_in_transactional_callbacks = true
  end
  </code></pre>
  
  <p>and before save it:</p>
  
  <pre><code>string = '7:05 PM ET'
  datetime = DateTime.now
  Time.use_zone('Eastern Time (US &amp; Canada)') do
        datetime = Time.zone.parse(string)
   end
  baz.create(time: datetime, foo: 'bar')
  </code></pre>
  
  <p>when i try to acces it </p>
  
  <pre><code>baz.where(time:Date.today.to_time.beginning_of_day..Date.today.to_time.end_of_day)
  </code></pre>