Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

Since you are referencing 'created_at', that's a value that gets parsed first. You can 'return' your own format.

For example purposes, try adding this to the model:

public function getMyCorrectFormatDate()
{
    return $this->created_at->format('d.m.Y');
}

then, you can call it using something like:

//controller
$model = Model::findOrFail(1); //Model being the model that contains getMyCorrectFormatDate() method
//template in blade
{{ $model->created_at; }}

Off the top of the head, so let me know if it even works.

Last updated 2 years ago.
0

Thanks for the help but I am using DB::RAW not eloquent. Also I am not using any blade templating. I am using

http://handlebarsjs.com/

Last updated 2 years ago.
0

I Figured it out, I just used

DB::raw('DATE_FORMAT(ideas.created_at,"%Y-%c-%d") as cdate')
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

kyoukhana kyoukhana Joined 28 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.