im trying to compare date from db on laravel but the comparison is failed probably wrong way to compare
$today = date("Y-m-d");
$dateUp= Jadwal::where('pembibitan', ">" ,strtotime($today))->get();;
$date= Jadwal::where('pembibitan', '<' ,strtotime($today))->get();;
return view('dashboard',['date'=>$date ,'dateUp'=>$dateUp, 'today'=>$today]);
the output end up with foreach display all data that exist on db
My Answer:
'Y-m-d');
$events = Event::where('date', '>=', $today)->get();
This code snippet should work for comparing dates from the database in Laravel. It retrieves all events where the date is greater than or equal to today's date. Make sure to adjust the date format in the 'date' column of your database table to match 'Y-m-d' format for accurate comparison.
Rate this post
4 of 5 based on 4600 votesComments