title: "Object of class DateTime could not be converted to string in"
body: <p>I have two bits of information and would like to save them comma delimited into a file. I would also like to save the timestamp. When I try to do so I get the error "Object of class DateTime could not be converted to string in..."</p>
  
  <p>When I echo the value it comes out fine but when I try to add it to the $data variable the error happens.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;?php
  
  
  $cont1 = $_POST['cont1'];
  
  $cont2 = $_POST['cont2'];
  
  
  $timestamp = new DateTime();
  $timestamp-&gt;format('Y-m-d H:i:s');
  
  
  $data = "Stuff: $cont1,$cont2,$timestamp";
      $fh = fopen("savestuff.txt", "a");
      fwrite($fh, $data."\r\n");
      fclose($fh);
  
  
  
  ?&gt;
  </code></pre>