1

I figured out how to format date: in model:

protected $dates = ['date'];

in view:

{{ $date->format('d/m') }}

How to display time in format h:m?

{{ $time }} this displays time h:m:s
3
  • easylaravelbook.com/blog/2015/02/11/… Commented Aug 9, 2017 at 17:36
  • This works for date, but how to make it work for time? Commented Aug 9, 2017 at 17:55
  • You have to pass the format string to the date object as described in that doc. Commented Aug 9, 2017 at 18:08

1 Answer 1

10

Try this

{{\Carbon\Carbon::createFromFormat('H:i:s',$time)->format('h:i')}}
Sign up to request clarification or add additional context in comments.

2 Comments

how to display AM and PM?
You can find the format in here: php.net/manual/en/function.date.php just pass the right letter in the format('g:i A') or format(g:i a')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.