Question and answer is powered by AnsPress.io
How to get data from the database to use order by date descending in laravel. I have got error when I have tried this code.
<?php orderBy("date_of_birth","desc") ?>
It will be better if you are using DATE_FORMAT in your order By option. Follow this example code, hope this code will work properly.
<?php $sec_data = DB::table("table anme")->select("*")->orderBy("(DATE_FORMAT(date_of_birth,'%Y-%m-%d')","desc")->get(); print_r($sec_data); ?>