I normally convert date to correct format for a query:
Y-m-d
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have table called "iklan", and i have column "waktupesan" format date example
2021-17-03
I want to display the data 2021-17-03 to my tabel, when im try to show data, The browser shows a different time than what I was looking for .
is my code for result.blade.php
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered" width="100%" cellspacing="0">
<thead>
<tr>
<th width="2%">#</th>
<th width="20%">Koran</th>
<th>Info Iklan</th>
<th width="20%">Diterima</th>
<th width="15%">Harga</th>
</tr>
</thead>
<tbody>
@php
$no=1;
@endphp
@foreach($orders as $order)
<tr>
<td>{{ $no++ }}</td>
<td>{{ $order->subdivisi }}</td>
<td>{{ $order->title }}</td>
<td>{{ $order->waktupesan }}</td>
<td>{{ $order->harga }}</td>
</tr>
@endforeach
</tbody>
</table>
<h5>Total: {{ $sum }}</h5>
</div>
</div>
ReportController
public function checkReport(Request $request){
if ($request->date){
$date = date('Y-d-m ', strtotime($request->date));
$orders = DB::table('iklan')->where('waktupesan',$date)->get();
$sum = DB::table('iklan')->where('waktupesan',$date)->sum('harga');
return view('laporan.result',compact('orders','sum','date'));
}
how i can fix it ?
Ok, so exactly as I described above; strtotime is returning false whenever it tries to handle that date string.
Just remove that line from your controller code; and pass $request->date directly into the query.
if ($request->date){
$date = $request->date;
$orders = DB::table('iklan')->where('waktupesan',$date)->get();
$sum = DB::table('iklan')->where('waktupesan',$date)->sum('harga');
return view('laporan.result',compact('orders','sum','date'));
}
Please or to participate in this conversation.