title: Warning: date_format() expects parameter 1 to be DateTime
body: <p>I am using the following script to pull the calendar info out of the mysql database and display it on the page. I am trying to re format the date from the standard Mysql date format , but when retrieving it from the database am getting the following error :</p>
  
  <pre><code>Warning: date_format() expects parameter 1 to be DateTime, string given in C:\easyphp\www\twinfocus\managecalendar.php on line 24
  
  Warning: date_format() expects parameter 1 to be DateTime, string given in C:\easyphp\www\twinfocus\managecalendar.php on line 24
  
  Warning: date_format() expects parameter 1 to be DateTime, string given in C:\easyphp\www\twinfocus\managecalendar.php on line 24
  
  Warning: date_format() expects parameter 1 to be DateTime, string given in C:\easyphp\www\twinfocus\managecalendar.php on line 24
  </code></pre>
  
  <p>The Database (as you can see the dates are stored correctly):
  <img src="https://i.stack.imgur.com/oFoCW.jpg" alt="enter image description here"></p>
  
  <p>The script :</p>
  
  <pre><code>&lt;?php
       $sql2 = &lt;&lt;&lt;SQL
          SELECT *
          FROM `calendar`
      SQL;
      if(!$result2 = $db-&gt;query($sql2)){ die('There was an error running the query [' . $db-&gt;error . ']');}
      echo '&lt;table class="admintable"&gt; &lt;thead&gt;';
      echo '&lt;tr&gt;&lt;th&gt;Client Names&lt;/th&gt;&lt;th&gt;Email&lt;/th&gt;&lt;th&gt;Tel&lt;/th&gt;&lt;th&gt;Wedding Date&lt;/th&gt;&lt;th&gt;Date Created&lt;/th&gt;&lt;th&gt;Start Time&lt;/th&gt;&lt;th&gt;End Time&lt;/th&gt;&lt;th&gt;Price&lt;/th&gt;&lt;th&gt;Location&lt;/th&gt;&lt;th&gt;Other Info&lt;/th&gt;&lt;th&gt;Edit&lt;/th&gt;&lt;th&gt;Delete&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;';
      while($row2 = $result2-&gt;fetch_assoc()){ 
      $weddingdate = $row2['weddingdate'];
      $formattedweddingdate = date_format($weddingdate, 'd-m-Y');
      echo '&lt;tr&gt;&lt;td&gt;'.$row2['name'].'&lt;/td&gt;&lt;td&gt;'.$row2['email'].'&lt;/td&gt;&lt;td&gt;'.$row2['tel'].'&lt;/td&gt;&lt;td style="min-width:70px;"&gt;'.$formattedweddingdate.'&lt;/td&gt;&lt;td style="min-width:70px;"&gt;'.$row2['datecreated'].'&lt;/td&gt;&lt;td&gt;'.$row2['starttime'].'&lt;/td&gt;&lt;td&gt;'.$row2['endtime'].'&lt;/td&gt;&lt;td&gt;&amp;pound;'.$row2['price'].'&lt;/td&gt;&lt;td&gt;'.$row2['location'].'&lt;/td&gt;&lt;td style="min-width:400px;"&gt;'.$row2['otherinfo'].'&lt;/td&gt;&lt;td&gt;&lt;a href="managecalendar.php?&amp;key='.$key.'&amp;editwedding='.$row2['id'].'"&gt;Edit&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href="calenderdelete.php?&amp;key='.$key.'&amp;delwedding='.$row2['id'].'"&gt;Delete&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;';}
      echo '&lt;/table&gt;';
  
  ?&gt;
  </code></pre>