I'm filtering a table data based on date range(Using vue2-date-range package). Initially the table data is loaded on 'This month' filter.
I've used the following code to get the start and end date of the current month -
dateRange: {
startDate: new Date(new Date().getFullYear(), new Date().getMonth(), 1),
endDate: new Date(new Date().getFullYear(), new Date().getMonth() + 1, 0)
},
I'm getting the following value as start and end date - "startDate":"2021-03-31T18:30:00.000Z","endDate":"2021-04-29T18:30:00.000Z"
.
Now in the backend I parse the above dates using Carbon package -
$startDate= Carbon::parse($search->startDate)->format('Y-m-d');
$endDate= Carbon::parse($search->endDate)->format('Y-m-d');
Now the date becomes - startDate - 2021-03-31 & endDate - 2021-04-29. But It should be 2021-04-01 & 2021-04-30 .
Why I'm getting different results.