I have a column in my table named expiry which has type VARCHAR. In the column, there is a mixture of date format like YYYY-MM-DD and MM-DD-YYYY.
How can i re-arrange the format MM-DD-YYYY to YYYY-MM-DD in my laravel view blade ?
View
@foreach($product_select as $key => $product)
<tr>
<td>{{$product->name}}</td>
<td>{{\Carbon\Carbon::parse($product->expiry)->isoFormat('YYYY MM DD')}}</td>
</tr>
@endforeach
In the view above, it throws an error
Could not parse '02-27-2021': DateTime::__construct(): Failed to parse time string (02-27-2021) at position 0
How can i solve this ?
Product Output
{#3504 ▼
+"product_id": "999"
+"id": 999
+"name": "CONFIDO CONFIDO TABS 60'S HIMALAYA"
+"code": "P935"
+"expiry": "03-31-2023"
+"type": "standard"
}
{{ \Carbon\Carbon::createFromFormat('m-d-Y', $product->expiry')->Format('Y m d')}}