title: Call to undefined method DateTime::format but DateTime is working
body: <p>I've gotten this really strange error all of a sudden in a legacy application we maintain.</p>
  
  <blockquote>
    <p><strong>Uncaught Error</strong>: Call to undefined method DateTime::format() in
    <strong>PATH</strong>/helpers.php:54</p>
  </blockquote>
  
  <p>My relevant code is this:</p>
  
  <pre><code>function custom_date_format($str, $format=false){
      if(!$format){
          $format ="j M Y";
      }
      $date = DateTime::createFromFormat('d-m-Y', $str);
      if($date){
          return $date-&gt;format($format); // lineno 54
      }
      return '';
  }
  </code></pre>
  
  <p>The server is running PHP 7 and <code>DateTime::createFromFormat</code> appears to be working so the <code>DateTime</code> object is working as it should.</p>
  
  <p>It stopped working overnight (which I find really strange, and not sure if I believe it). </p>
  
  <p>Any idea's of such strange errors?</p>