Date Format
Hi, i'm having problems formatting the dates, i have a table in mysql with three dates timeinit, created_at, updated_at, to first one i want to give it a format like this, '2015-10-21 11:31:00.523000', so i read in the documentation that i have to use the $dateFormat property in my model like this: protected $dateFormat = 'Y-m-d h:i:s.u'; But when i do this the other two dates (created_at and updated_at) fail, this two dates are the regular dates from laravel, the documentation also says that i can use the $date field that specified the dates are going to be mutated like this: protected $dates = ['timeinit']; But my app keep failing saying that the format for created_at is not like 'Y-m-d h:i:s.u'.
i decided to insert the dates manually, using DB::table('trxes')->insert(), works greate, it saves the time with the .u format, but when i list the data in my view it doesn't show the microseconds and i need it.
i think i have to use a mutator for this, so i create one,
public function getTimeinitAttribute($date){ $dt = new \DateTime($date); return Carbon::instance($dt)->format('Y-m-d h:i:s.u') }
but the view still shows 2015-10-21 11:31:00
Please or to participate in this conversation.