I'm having a problem with my date format. created_at
does not display the same date as in my database. but due_date
is working fine. Before this I used $c->created_at->format("d/m/yy")
and the flow was okay but for certain reason I need to change it. It is because now I use this code in my index():
$pending = DB::table('complaints')
->join('defects','complaints.defect_id','=','defects.id')
->where('complaints.contractor_id','=',Auth::user()->typable_id)
->where('complaints.status','=','Pending')
->get();
return view('contractors.complaints.index.pending', compact('pending'));
If I use above code with $c->created_at->format("d/m/yy")
in my view, it will shows error something like format() on string?
The problem occur here, in my view:
{{date('d/m/yy', strtotime($c->created_at))}}
{{date('d/m/yy', strtotime($c->due_date))}}
Controller
if (count($request->defect_id) > 0) {
foreach($request->defect_id as $item=>$v) {
$data = array(
'created_at' => Carbon::today()->toDateString(),
'due_date' => Carbon::today()->addDays(30),
'updated_at' => Carbon::now()->toDateTimeString(),
);
Complaint::insert($data);
It still counting the addDays(30)
. It just the created_at
display 14/10/2020
even though I created it just now, supposedly it displays 16/10/2020
. What I need to do to make sure my controller and view is working perfectly without any error?