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.
The signature of the now
function is:
1function now(2 $tz = null3);
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');
∎