title: Ruby on Rails 3: Why is the conversion from Date to seconds different from Time to seconds
body: <p>In Ruby I am trying to convert a Date into a format that is usable by the <code>HighCharts</code> JavaScript charting library. Odd thing is when I convert the Date to seconds it converts differently than when I convert a <code>Time</code> to seconds and differently when I convert a <code>DateTime</code> to seconds. Due to this difference in conversion the dates displayed on the Graph can be as much as 1 date behind. </p>
  
  <p>I am sure this has something to do with Rails and how it handles conversion from UTC to Local. If someone could explain to me the details I would greatly appreciate it. </p>
  
  <p>In my examples below I use the same date '2011/05/02' but the seconds come out to be different. </p>
  
  <p>Examples:</p>
  
  <pre><code>Date.new(2011, 5, 2).to_time.to_i * 1000
  =&gt; 1304265600000
  =&gt; 05/01/2011
  
  Time.utc(2011, 5, 2).to_i * 1000
  =&gt; 1304294400000
  =&gt; 05/02/2011
  
  Date.new(2011, 5, 2).to_datetime.to_i * 1000
  =&gt; 1304294400000
  =&gt; 05/02/2011
  </code></pre>