title: Compare datetime objects in Rails
body: <p>I'm trying to compare two DateTime objects. However, I don't quite understand the result.</p>
  
  <pre><code>DateTime.parse("2014-09-14 01:12:03 +0200")
  &gt;&gt; Sun, 14 Sep 2014 01:12:03 +0200   
  
  Foo.order("created_at").last.created_at.to_datetime
  &gt;&gt; Sun, 14 Sep 2014 01:12:03 +0200
  </code></pre>
  
  <p>But </p>
  
  <pre><code>Foo.order("created_at").last.created_at.to_datetime === DateTime.parse("2014-09-14 01:12:03 +0200")
  true
  
  Foo.order("created_at").last.created_at.to_datetime &gt; DateTime.parse("2014-09-14 01:12:03 +0200")
  true
  </code></pre>
  
  <p>Why is the result of the <code>&gt;</code> comparison not <code>false</code>? (Rails 4.0.9)</p>
  
  <p>Edit: I got it working using the <code>===</code> operator. But it still returns <code>true</code> when I use the <code>&gt;</code> operator. </p>