I want to get the first date and last date of the month if given I have a numeric number of the month.
For example January = 01, October = 10, November = 11
So if I pass 10 as parameter I should get the first and last date of October.
I tried to implement it using Carbon. But I gives me different result.
Here is the code. The result is is next to it.
$dt = Carbon::create(10);
echo $dt->startOfMonth(); // 0010-10-01 00:00:00
echo $dt->endOfMonth(); // 0010-10-31 00:00:00
The first day of any month is the first.
$dt = Carbon::createFromFormat('m', 10); echo $dt->endOfMonth();