DEV Community

Morcos Gad
Morcos Gad

Posted on

2 1

The Wonderful Carbon - Laravel

Today I am talking about a great simple PHP API extension for DateTime that we use a lot in our projects, but I wanted to have a closer look at it.

At first we go to https://carbon.nesbot.com/ Here we will see a lot of interesting information and go deeper into it
See also https://github.com/briannesbitt/Carbon

  • See a short tip on the benefit
$user->created_at->diffForHumans();
=> "17 hours ago"

$user->created_at->diffForHumans([
     'parts' => 2
]);
=> "17 hours 54 minutes ago"

$user->created_at->diffForHumans([
     'parts' => 3
     'join' => ', ',
]);
=> "17 hours, 54 minutes, 50 seconds ago"

$user->created_at->diffForHumans([
     'parts' => 3,
     'join' => ', ',
     'short' => true,
]);
=> "17h, 54m, 50s ago"
Enter fullscreen mode Exit fullscreen mode

I hope you enjoyed the article and I hope you always enjoy the code .

Top comments (0)

Cloudinary image

Optimize, customize, deliver, manage and analyze your images.

Remove background in all your web images at the same time, use outpainting to expand images with matching content, remove objects via open-set object detection and fill, recolor, crop, resize... Discover these and hundreds more ways to manage your web images and videos on a scale.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay