title: Fatal error: Call to a member function format() on a non-object
body: <p>I have an html file which has the following table:</p>
  
  <pre><code>&lt;form action="wedding-ajax-support.php" method="get" id="wedding-table"&gt;
  &lt;table border="0"; align="center"&gt;
    &lt;tr&gt;
      &lt;th scope="col"&gt;Key&lt;/th&gt;
      &lt;th scope="col"&gt;Value&lt;/th&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;label for="date"&gt;Select the date on which your party will take place (mm/dd/yyyy): &lt;/label&gt;&lt;/td&gt;
  
      &lt;td&gt;
        &lt;input name="date" type="text" class="larger" id="date"  size="12" /&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;label for="catering"&gt;Type the catering grade you would like (from 1 to 5) : &lt;/label&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input name="catering" type="text" class="larger" id="catering"  size="5" /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;label for="size"&gt;Type the number of people you are expecting to attend: &lt;/label&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input name="size" type="text" class="larger" id="size"  size="5" /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Find me available venues, based on my preferences: &lt;/td&gt;
      &lt;td&gt;&lt;input type="submit" name="submit" id="submit" value="GO!" class="larger" /&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p></p>
  
  <blockquote>
    <p>One of those inputs is the date. That's the only thing I'm concerned about for now, to keep things simple.</p>
    
    <p>On another file, wedding-ajax-support.php (on which I organize all of my php code) I have this amongst other code: </p>
  </blockquote>
  
  <pre><code>$date = DateTime::createFromFormat('m/d/Y', $_GET['date']);
  </code></pre>
  
  <p>$date = $date->format('Y-m-d'); // Changes the format of the date, as the date entered by the user, and the date in the database are of a different format.</p>
  
  <blockquote>
    <p>And then a simple echo $date;
    just to test it.</p>
  </blockquote>
  
  <p>Then, back at my main file, I put a </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  </code></pre>
  
  <p>$("#wedding-table").load("wedding-ajax-support.php");</p>
  
  <p></p>
  
  <p>to replace the table with the date in changed format, using ajax via jQuery.</p>
  
  <p>So, when I load my webpage, where the table should have been, a message is displayed 
  "Fatal error: Call to a member function format() on a non-object in /disks/diskh/zco/cotm2/public_html/wedding/wedding-ajax-support.php on line 23 Call Stack: 0.0002 333936 1. {main}() /disks/diskh/zco/cotm2/public_html/wedding/wedding-ajax-support.php:0 ".</p>
  
  <blockquote>
    <p>Any ideas/suggestions would be appreciated, thanks in advance!</p>
  </blockquote>