echo `{{$result->created_at}}`
result is 2018-06-23 08:05:14
but I want to echo just date. not time
I mean echo only 2018-06-23 not 2018-06-23 08:05:14
echo `{{$result->created_at}}`
result is 2018-06-23 08:05:14
but I want to echo just date. not time
I mean echo only 2018-06-23 not 2018-06-23 08:05:14
It's a Carbon instance. The recommended option is simply
{{ $result->created_at->toDateString() }}
Carbon docs: https://carbon.nesbot.com/docs/#api-formatting
This is pretty simple, directly escape date to whichever format you want like in the example below
{{ date('Y-m-d', strtotime($result->created_at))}}
You may handle this on the PHP side by just using substr
:
echo {{ substr($result->created_at, 0, 10) }}
There are also ways that you could handle the formatting on the MySQL side, e.g. by using DATE_FORMAT
:
DATE_FORMAT(created_at, '%Y-%m-%d')