简体   繁体   中英

Laravel formatting a date in_array

Having trouble formatting the date in a Laravel application. It's currently showing the date like so:

Monday, 15:00:00

I would like the 15:00:00 to be in the following format:

3:00pm (g:ia)

I tried to wrap using Carbon using: \\Carbon\\Carbon::parse(...)->format('g:ia') but returned errors.

@foreach($days[$index] as $dateIndex => $day)
   @if($day == 'Monday')
      Monday, {{ in_array($dates[$index][$dateIndex], $date[$index]) ? 'Not Available' : $club->monday }}
   @endif
@endforeach

Thanks.

Thanks for your help guys.

I need to wrap $club->monday with carbon format.

\Carbon\Carbon::parse($club->monday)->format('g:ia')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM