Getting current date, time, and day in Laravel [duplicate]

Laravel has the Carbon dependency attached to it.

Carbon::now(), include the Carbon\Carbon namespace if necessary.

Edit (usage and docs)

Say I want to retrieve the date and time and output it as a string.

$mytime = Carbon\Carbon::now();
echo $mytime->toDateTimeString();

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.

Documentation:
https://github.com/briannesbitt/Carbon

String formats for Carbon:
http://carbon.nesbot.com/docs/#api-formatting

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)