title: PHP + MongoClient + MongoDate , operand not working on nested elements
body: <p>I've got an headache that I would like to share with you :)</p>
  
  <p>This is my code (portion of a small project I'm doing in php+mongo):</p>
  
  <pre><code>&lt;?php
  $db = new MongoClient('mongodb://localhost');
  $db-&gt;connect();
  $collection = $db-&gt;{'someDb'}-&gt;{'someCollection'};
  print '********************************************' . PHP_EOL;
  print '********          SAVE           ***********' . PHP_EOL;
  print '********************************************' . PHP_EOL;
  $obj = array(
      "_id" =&gt;new MongoId(),
      "dob" =&gt; new MongoDate(strtotime("1983-08-31T04:00:00Z")),
      "name" =&gt;"Author [541a88934d1ed8.64628062]",
      "password" =&gt; "229fe88b25ae8307601bf6c9c050bf02755b7e26",
      "timezone" =&gt; "Australia/Sydney",
      "expiry" =&gt; new MongoDate(strtotime("2015-09-18T07:24:03Z")),
      "token" =&gt; array(
          0 =&gt; array(
              "title" =&gt; "API Test",
              "hash" =&gt; "ce9808c5063f114f21cbf2d7e194caeccd17d0ae",
              "expiry" =&gt; new MongoDate(strtotime("2015-09-18T07:24:03Z"))
          )
      )
  );
  print_r($obj);
  $collection-&gt;save($obj);
  print '********************************************' . PHP_EOL;
  print '********         SEARCH          ***********' . PHP_EOL;
  print '********************************************' . PHP_EOL;
  $where = array(
      'token.hash' =&gt; 'ce9808c5063f114f21cbf2d7e194caeccd17d0ae',
      'expiry' =&gt; array('$lt' =&gt; new \MongoDate())
  );
  print '&gt;&gt;&gt; CRITERIA ' . PHP_EOL;
  print_r($where);
  print '&gt;&gt;&gt; RESULT ' . PHP_EOL;
  $cursor = $collection-&gt;find()-&gt;limit(1);
  $result = iterator_to_array($cursor);
  $result = array_shift($result);
  print_r($result);
  print '********************************************' . PHP_EOL;
  print '********     NESTED SEARCH       ***********' . PHP_EOL;
  print '********************************************' . PHP_EOL;
  $where = array(
      'token.hash' =&gt; 'ce9808c5063f114f21cbf2d7e194caeccd17d0ae',
      'token.expiry' =&gt; array('$lt' =&gt; new \MongoDate())
  );
  print '&gt;&gt;&gt; CRITERIA ' . PHP_EOL;
  print_r($where);
  $cursor = $collection-&gt;find($where)-&gt;limit(1);
  $result = iterator_to_array($cursor);
  $result = array_shift($result);
  print '&gt;&gt;&gt; RESULT ' . PHP_EOL;
  var_dump($result);
  </code></pre>
  
  <p>The first search work perfectly, but the second search does not work as expected, check out the result:</p>
  
  <pre><code>********************************************
  ********          SAVE           ***********
  ********************************************
  Array
  (
      [_id] =&gt; MongoId Object
          (
              [$id] =&gt; 541a9111c48e5859108b4567
          )
  
      [dob] =&gt; MongoDate Object
          (
              [sec] =&gt; 431150400
              [usec] =&gt; 0
          )
  
      [name] =&gt; Author [541a88934d1ed8.64628062]
      [password] =&gt; 229fe88b25ae8307601bf6c9c050bf02755b7e26
      [timezone] =&gt; Australia/Sydney
      [expiry] =&gt; MongoDate Object
          (
              [sec] =&gt; 1442561043
              [usec] =&gt; 0
          )
  
      [token] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [title] =&gt; API Test
                      [hash] =&gt; ce9808c5063f114f21cbf2d7e194caeccd17d0ae
                      [expiry] =&gt; MongoDate Object
                          (
                              [sec] =&gt; 1442561043
                              [usec] =&gt; 0
                          )
  
                  )
  
          )
  
  )
  ********************************************
  ********         SEARCH          ***********
  ********************************************
  &gt;&gt;&gt; CRITERIA 
  Array
  (
      [token.hash] =&gt; ce9808c5063f114f21cbf2d7e194caeccd17d0ae
      [expiry] =&gt; Array
          (
              [$lt] =&gt; MongoDate Object
                  (
                      [sec] =&gt; 1411027217
                      [usec] =&gt; 868000
                  )
  
          )
  
  )
  &gt;&gt;&gt; RESULT 
  Array
  (
      [_id] =&gt; MongoId Object
          (
              [$id] =&gt; 541a8e23c48e58700f8b4567
          )
  
      [dob] =&gt; MongoDate Object
          (
              [sec] =&gt; 431150400
              [usec] =&gt; 0
          )
  
      [name] =&gt; Author [541a88934d1ed8.64628062]
      [password] =&gt; 229fe88b25ae8307601bf6c9c050bf02755b7e26
      [timezone] =&gt; Australia/Sydney
      [token] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [title] =&gt; API Test
                      [hash] =&gt; ce9808c5063f114f21cbf2d7e194caeccd17d0ae
                      [expiry] =&gt; MongoDate Object
                          (
                              [sec] =&gt; 1442561043
                              [usec] =&gt; 0
                          )
  
                  )
  
          )
  
  )
  ********************************************
  ********     NESTED SEARCH       ***********
  ********************************************
  &gt;&gt;&gt; CRITERIA 
  Array
  (
      [token.hash] =&gt; ce9808c5063f114f21cbf2d7e194caeccd17d0ae
      [token.expiry] =&gt; Array
          (
              [$lt] =&gt; MongoDate Object
                  (
                      [sec] =&gt; 1411027217
                      [usec] =&gt; 870000
                  )
  
          )
  
  )
  &gt;&gt;&gt; RESULT 
  NULL
  </code></pre>
  
  <p>I'm not a MongoDb guru, just a poor programmer trying to save his day, any one got any idea why this is happening? What Am I doing wrong?</p>
  
  <p>PHP Version:</p>
  
  <pre><code>valerio@beatrice:~$ php -v
  PHP 5.5.9-1ubuntu4.4 (cli) (built: Sep  4 2014 06:56:34) 
  Copyright (c) 1997-2014 The PHP Group
  Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
  with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
  valerio@beatrice:~$ 
  </code></pre>
  
  <p>MongoDb driver info (from php -info)</p>
  
  <pre><code>MongoDB Support =&gt; enabled
  Version =&gt; 1.4.5
  SSL Support =&gt; enabled
  Streams Support =&gt; enabled
  
  Directive =&gt; Local Value =&gt; Master Value
  mongo.allow_empty_keys =&gt; 0 =&gt; 0
  mongo.chunk_size =&gt; 262144 =&gt; 262144
  mongo.cmd =&gt; $ =&gt; $
  mongo.default_host =&gt; localhost =&gt; localhost
  mongo.default_port =&gt; 27017 =&gt; 27017
  mongo.is_master_interval =&gt; 15 =&gt; 15
  mongo.long_as_object =&gt; 0 =&gt; 0
  mongo.native_long =&gt; 0 =&gt; 0
  mongo.ping_interval =&gt; 5 =&gt; 5
  </code></pre>