PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, February 12, 2022

[FIXED] How to get the only hours and minutes in laravel blade?

 February 12, 2022     datetime, laravel, laravel-blade, php     No comments   

Issue

I am trying to get hours and minutes and seconds in blade, normally I use like below

{{$calllog['delivery_date']}}

but now my requirement is to get hours and minutes and seconds. here is how I tried to get

$calllog['delivery_date']->todatestring()}}

Yeah, I think I misuse for this function, can someone help me out? I am new in Laravel. Any help would be greatly appreciated.


Solution

If your variable is a DateTime, you can use this :

{{ Carbon\Carbon::parse($calllog['delivery_date'])->format('H:i:s') }}

Or simplest way (depends on your version) :

{{ $calllog['delivery_date']->format('H:i:s') }}


Answered By - Vincent Decaux
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing