Skip to content
Advertisement

How to format time data type in laravel

How can I format time data type in laravel? Please see my code below.

Model

protected $dates = ['start_date', 'end_date', 'show_at', 'hide_at', 'created_at', 'updated_at'];

View

{{ $promotion->show_at->format('h:i:s A') }}

Data from database (type: time)

23:59:59

Error

Unexpected data found. Unexpected data found.

Advertisement

Answer

please try:

{{ Carbon::parse($promotion->show_at)->format('H:i:s') }}
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement