Level 39
Use ->whereDate('created_at', $date)
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
in the blade file, I have a form with input as the date
<form action="{{ route('searchreportresultdate') }}" method="POST" >
@csrf
<div class="modal-body pd-20">
<div class="form-group">
<label for="brand name">Seach By Date</label>
<input type="date" required name="date" id="name" value="" class="form-control">
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-info pd-x-20">Submit</button>
</div>
</form>
in the controller, i want to check the date passed from the form and product created timestamp(created_at)
while dd($result) i am getting nothing
public function searchreportresultdate(Request $request){
$date=$request->date; //=2021-2-20
$result=Product::where('status',1)->where('created_at',$date)->get();
dd($result);
}
i think the date in the database is in y-m-d h:m:s how that h:m:s can be excluded and get the only created_at in format=Y-m-d
Use ->whereDate('created_at', $date)
Please or to participate in this conversation.