Laravel 5: Getting the Current Date and Time With now

April 15, 2018 —John Koster

The now helper function will return a new Carbon instance initialized to the current date and time. The now function accepts an optional timezone parameter to adjust the timezone of the returned date.

#Signature

The signature of the now function is:

1function now(
2 $tz = null
3);

#Example Use

The following example demonstrates the usage of the now helper function.

1// Get the current Atom formatted date and time.
2$atomDateTime = now()->toAtomString();
3 
4// Get the current date and time for America/Toronto.
5$americaToronto = now('America/Toronto');

Some absolutely amazing
people

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.