title: Call to a member function format() on string in laravel
body: <p>I am passing the <code>fromdate</code> and <code>todate</code> from the view to controller. I want to print the betweens these dates from the database, but I get error like: </p>
  
  <blockquote>
    <p>Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
    Call to a member function format() on string</p>
  </blockquote>
  
  <p><strong>my view page</strong>:</p>
  
  <pre><code>&lt;div class="col-sm-4"&gt;
      {!! Form::open (['url' =&gt; 'admin/ad']) !!}
      &lt;div class="form-group"&gt;
          {!! Form::label('', 'From date') !!}
          {!! Form::date('fromdate', '', ['class' =&gt; 'form-control']) !!}
          {!! Form::label('', 'To date') !!}
          {!! Form::date('todate', '', ['class' =&gt; 'form-control']) !!}
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          {!! Form::submit(('submit'), ['class' =&gt; 'btn btn-primary btn-block']) !!}
          {!! Form::close() !!}
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>my controller page</strong>:</p>
  
  <pre><code>$report = $request-&gt;report;
  $fromdate = $request-&gt;fromdate; 
  $start_date = date("Y-m-d H:i:s", strtotime($fromdate));
  $todate = $request-&gt;todate;
  $end_date = date("Y-m-d H:i:s", strtotime($todate));
  
  $users = Report::whereBetween('created_at', [
      $start_date-&gt;format('Y-m-d') . " 00:00:00",
      $end_date-&gt;format('Y-m-d') . " 23:59:59"
  ])-&gt;get();
  </code></pre>