Search code examples
phplaraveldatetimephp-carbon

Convert a datetime into human understandable form


There is one class in laravel named Carbon and it is used to format dates into what they call as diffForHumans(). So, I have a date that looks like this:

2018-07-15 17:03:19

So, How do I convert it into diffForHumans? Thanks!


Solution

  • Like this:

    $date = \Carbon\Carbon::parse("2018-07-15 17:03:19")->diffForHumans();
    

    Seriously? I get downvoted for answering his question?