Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How format date Carbon:now() in Laravel PHP [duplicate]

I tried

 update(['access' => Carbon::now()->format('Y/m/d H:i:s')]);

it returned Y-m-d H:i:s

like image 602
ThaiVD Avatar asked Jul 06 '18 04:07

ThaiVD


People also ask

How do I change the date format in Laravel query?

You can always use Carbon's ->format('m/d/Y'); to change format. Or you can just use selectRaw to build your queries. Save this answer.

How do I change a date format to a string in Laravel?

So, let's add these variables to config/app. return [ 'date_format' => 'm/d/Y', 'date_format_javascript' => 'MM/DD/YYYY', ]; And then, in Laravel, we can use this: Carbon::createFromFormat(config('app. date_format'), $value)->format('Y-m-d'); Carbon::parse($value)->format(config('app.


1 Answers

now()->format('Y-m-d H:i:s')

You Can Format like above code simply.

like image 183
JOY KUMAR PAL Avatar answered Sep 18 '22 21:09

JOY KUMAR PAL