title: Comparing two dates in blade.php file
body: <p>I have to compare two dates in a list.blade.php like  </p>
  
  <blockquote>
    <p>if today's date is greater than or equal to expiry date then do something else do something.</p>
  </blockquote>
  
  <p>here is the code:</p>
  
  <pre><code>@php
  use Carbon\Carbon;
  $today_date = Carbon::today();
  @endphp
  
  @foreach ($entries as $k =&gt; $entry)
  @if($today_date &gt;= $entry-&gt;expire_date)
  // do something
  @else 
  // do something
  @endif
  @endforeach
  </code></pre>
  
  <blockquote>
    <p>Date format: YYYY-MM-DD</p>
  </blockquote>
  
  <p>But this is not working.</p>
  
  <p>Please help</p>
  
  <p>Thanks </p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I tried this:</p>
  
  <pre><code>&lt;?php
      use Carbon\Carbon;
      $today_date = Carbon::now();
  
      foreach ($entries as $k =&gt; $entry) {
          $expire_date = Carbon::createFromFormat('Y-m-d', $entry-&gt;expire_date);
      }
  ?&gt;
  </code></pre>
  
  <p>and it gives me error like:
  <a href="https://i.stack.imgur.com/UX5sh.png" rel="nofollow noreferrer">image</a></p>
  
  <p>One more thing <code>expire_date</code> is of text type in my database so this might be the problem.</p>