Working with date and time in PHP is not the easiest or most clear of tasks. We have to deal with strtotime, formatting issues, lots of calculations, and more.

The nifty package called Carbon can help make dealing with date/time in PHP much easier and more semantic so that our code can become more readable and maintainable.

Carbon

Carbon is a package by Brian Nesbit that extends PHP’s own DateTime class.

enter image description here

It provides some nice functionality to deal with dates in PHP. Specifically things like:

Dealing with timezones

Getting current time easily

Converting a datetime into something readable

Parse an English phrase into datetime (first day of January 2016)

Add and Subtract dates (+ 2 weeks, -6 months)

Semantic way of dealing with dates

All of the above lead to a very useful package that makes it a breeze to deal with times in PHP.