You can use this approach where new Date()
is like Sat Aug 24 2019 20:36:26 GMT+0600 (Bangladesh Standard Time)
first use following JavaScript function for parsing new Date()
function datefilter(date){
let month = date.getMonth();
let year = date.getFullYear();
let day = date.getDate();
return day+'-'+month + '-' + year;
}
datafilter(new Date());
The output will be "24-7-2019"
then use Carbon createFromFormate like
Carbon::createFromFormat('d-m-Y', $data['enddate']);
I guess output will remain to same"24-7-2019"