title: Finding days between two dates in laravel
body: <p>I have to dates. Now, I need to find the difference between these two for further calculations. </p>
  
  <p>I tried different ways but I am not able to fix the issues. Can anyone tell me the best way to do it.</p>
  
  <p>My code is: </p>
  
  <pre><code>public function leaveRequest(request $request)
  {
      $fdate=$request-&gt;Fdate;
      $tdate=$request-&gt;Tdate;
  
      $start = Carbon::parse($fdate)-&gt;format('Y/m/d');
      $end =  Carbon::parse($tdate)-&gt;format('Y/m/d');
  
      $days = $end-&gt;diffInDays($start);
      /*$days=date_diff($end,$start);*/
      echo $days;
      exit;
  
      $user = User::findOrFail(Auth::user()-&gt;id);
      Mail::send('pages.leave', ['user' =&gt; $request,'userId'=&gt;$user], function ($m) use ($request) {
          $m-&gt;to($request-&gt;Email)-&gt;subject('Leave Request!');
      });
  
      DB::table('leaves')-&gt;insert(
          ['user' =&gt; Auth::user()-&gt;id, 'request_date' =&gt; Carbon::now(),'start' =&gt; $start,'end' =&gt; $end,'permissions' =&gt; "Pending",'leave_status' =&gt; "Active"]
      );
  
      return redirect()-&gt;back()-&gt;with('message','Your request has sent');
  }
  </code></pre>
  
  <p>If I can get the days then I can insert it into the leaves table.</p>