@anonymouse703 what is value of $event->start? it's time 17:00:00?
dd($event->start);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
This code is depracated already but how to do this in Laravel 8? I want to display my start time and end time in AM and PM and the date into Month, Day, year
ex. 17:00:00 to 22:00:00 inyo 5:00 PM to 10:PM
Here is the deprecated code:
{{$event->start->format('h:i:s A')}} to {{$event->end}}
I also try this from the document but nothing happened
<?php echo ($event->start)->format('h:i:s A'); ?>
and also the date
ex. 2021-08-21 to August, 21, 2021
Thanks.
I did not know that, thanks!
To use the casts u can do this in the model
protected $casts = [
'start' => 'datetime',
'end' => 'datetime',
'date_of_event' => 'date',
];
public function getEventStartAttribute()
{
return $this->date_of_event->format('F j, Y') . ' ' .$this->start->format('g:i A');
}
And in the view:
{{ $event->event_start }} => "January 1, 2021 5:00 PM"
PS. @snapey came up with making the accessor..
Please or to participate in this conversation.