Get the Current Date With today: Laravel

The today helper function is similar to the now helper function in that it returns a Carbon for the current date, however, the difference is that the today helper function only returns the date component; the time component is set to 00:00:00.

It depends on what you want to do with the date! Carbon\Carbon::now() will give you a Carbon instance with the current date. If you need it in a particular format, then use Carbon's available methods to manipulate it.

The today function also accepts an optional timezone parameter to adjust the timezone of the returned Carbon instance.

Signature

The signature of the today function is:
function today(
    $tz = null
);

Example Use

The following example demonstrates the usage of the today helper function to get the current date:


// Get the current day of the year.
$dayOfYear = today()->dayOfYear;
// Supply a timezone and get the day of the week.
$dayOfWeek = today('Europe/London')->dayOfWeek;

This will output in the usual format of Y-m-d H:i:s, there are many pre-created formats and you will unlikely need to mess with PHP date time strings again with Carbon.