How to display 1 day ago in comments in laravel view

Updated at 06-Aug-2021, By samar

How to display 1 day ago in comments in laravel view

We’ll attempt to use programming in this lesson to solve the "How to display 1 day ago in comments in laravel view" puzzle.

You can display the date or time (Ex. 1 day ago, 23 hours ago) in comments at the time of comment has been created on a post in laravel view.
  • DiffForHumans() method on created_at in laravel view

    {{ $comment->created_at->diffForHumans() }}
    
    //output 
    23 hours ago
    

    You can display the time (1 day ago, or 23 hours ago) at the comment that has been created or commented on a post in laravel using the diffForHumans() method on carbon.

Back to code snippet queries related laravel