title: DateTime::__construct(): Failed to parse time string (16/07/2020) at position 0 (1): Unexpected character
body: <p>In my Laravel 5.8 application, I have:</p>
  <p><code>config/app.php</code></p>
  <pre class="lang-php prettyprint-override"><code>'date_format' =&gt; 'd/m/Y',
  'date_format_js' =&gt; 'dd/mm/yy',
  </code></pre>
  <p>Model</p>
  <pre class="lang-php prettyprint-override"><code>use Carbon\Carbon;
  
  class HrHolidayDate extends Model
  {
      protected $table = 'hr_holiday_dates';
  
      protected $fillable = [
          'holiday_name',
          'holiday_date',
  
      ];
  
      protected $dates = [
          'holiday_date'
      ];
  
  
      protected $casts = [];
  
  
      public function setHolidayDateAttribute($input)
      {
          $this-&gt;attributes['holiday_date'] =
              Carbon::createFromFormat(config('app.date_format'), $input)-&gt;format('Y-m-d');
      }
  
  
      public function getHolidayDateAttribute($input)
      {
          return Carbon::createFromFormat('Y-m-d', $input)
              -&gt;format(config('app.date_format'));
      }
  }
  </code></pre>
  <p>I tried to format it in the Blae view as shown below:</p>
  <p><code>view</code></p>
  <pre class="lang-html prettyprint-override"><code>@foreach($holidays as $key =&gt; $holiday)
      &lt;td&gt;
          {{Carbon\Carbon::parse($holiday-&gt;holiday_date)-&gt;format('d-m-Y') ?? '' }}
      &lt;/td&gt;
  @endforeach
  </code></pre>
  <p>When I wanted to render the view blade, I got this error:</p>
  <blockquote>
  <p>[2020-07-15 11:57:56] production.ERROR: DateTime::__construct(): Failed to parse time string (16/07/2020) at position 0 (1): Unexpected character (View: C:\xampp\htdocs\laravelapp\resources\views\hr\holiday_dates\index.blade.php) {&quot;userId&quot;:466,&quot;exception&quot;:&quot;[object] (ErrorException(code: 0): DateTime::__construct(): Failed to parse time string (16/07/2020) at position 0 (1): Unexpected character (View: C:\xampp\htdocs\laravelapp<br />
  esources\views\hr\holiday_dates\index.blade.php) at C:\xampp\htdocs\laravelapp\vendor<br />
  esbot\carbon\src\Carbon\Traits\Creator.php:81, Exception(code: 0): DateTime::__construct(): Failed to parse time string (16/07/2020) at position 0 (1): Unexpected character at C:\xampp\htdocs\laravelapp\vendor<br />
  esbot\carbon\src\Carbon\Traits\Creator.php:81)
  [stacktrace]</p>
  </blockquote>
  <p>How do I resolve it?</p>
  <p>Thanks</p>