How to display 1 day ago in comments in laravel view

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.

Answers 1
  • DiffForHumans() method on created_at in laravel view

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

    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