$period = new DatePeriod(
new DateTime( '2024-03-20 00:00:00' ),
new DateInterval('P1D'),
new DateTime( '2024-03-28 23:59:59' )
);
$orders = OrderProduct::where ('brand','<>','NULL');
foreach ($period as $date){
$labels[] = $date->format('d-m-Y');
$searchDate = $date->format('Y-m-d'); **//This doesn't work**
//$searchDate = '2024-03-26'; **//This works**
$order = $orders->whereDate( 'updated_at','=',$searchDate )->get();
foreach ($order as $item){
if( $item ){
Log::info( $item->brand );
}
}
}
As you see when I try //This works line. It works but when I use code like above it doesn’t work. I have checked $searchDate with gettype() and it shows string. My database postgresql and updated_at field like = 2024-03-26 09:17:01
New contributor
Ferhat Nalbant is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.