April 15, 2018 —John Koster
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
.
The today
function also accepts an optional timezone parameter to adjust the timezone of the returned Carbon instance.
The signature of the today
function is:
1function today(2 $tz = null3);
The following example demonstrates the usage of the today
helper function to get the current date:
1// Get the current day of the year.2$dayOfYear = today()->dayOfYear;3 4// Supply a timezone and get the day of the week.5$dayOfWeek = today('Europe/London')->dayOfWeek;
∎
The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.