title: Date conversion and updating mongodb document using PHP
body: <p>Progress :<br>
  1. I retireved date from a collection.
     Example format :  Fri Oct 05 14:59:31 +0000 2012<br>
  2. I was able to change its  format.</p>
  
  <p>CODE USED :</p>
  
  <pre><code>         $cur=$col-&gt;find(array(),array("created_at"=&gt;1,"_id"=&gt;0));
            // created_at = contains Date value
  $cur_all=$col-&gt;find();
  while($doc=$cur_all-&gt;getNext())
  {
          $doc2=$cur-&gt;getNext();
          $pieces = implode(" ", $doc2);
                      //converted the array to string with space delimiting
          if($pieces!=NULL)
          {
              $date1 = date_create_from_format("D M d G:i:s +O Y", $pieces);
              echo date_format ( $date1 ,  'Y-m-d G:i:s' );
              //This is the format i  would like to update in mongodb..
  
  
              $filter = array('_id'=&gt;new MongoId($doc['_id']));
              $update = array('$set'=&gt;array('created_at'=&gt; newMongoDate($date2)));
              $col-&gt;update($filter,$update);
          }
  }
  </code></pre>
  
  <p>QUESTION :</p>
  
  <p>Where to create a date object so that it could be updated to the documents in the collection in the expected format? (format : Y-m-d G:i:s )</p>
  
  <p>P.S : I did a lot of research on Stackoverflow (And other places, as well.) but I could not come to any conclusions. That is why this question. Let me know if there are any clarifications</p>