jcadima
6/3/2018 - 4:44 PM

Find start/end day of previous month


https://stackoverflow.com/questions/37153903/how-to-get-first-and-last-day-of-previous-month-with-carbon-laravel
<?php 

$start = new \Carbon\Carbon('first day of last month');
$end = new \Carbon\Carbon('last day of last month');



$firstDayofPreviousMonth = Carbon::now()->startOfMonth()->subMonth()->toDateString();
$lastDayofPreviousMonth = Carbon::now()->subMonth()->endOfMonth()->toDateString();



// With this ... the date start init on 00:00 and date end finish in 23:59
$start = new Carbon('first day of last month');
$start->startOfMonth();
$end = new Carbon('last day of last month');
$end->endOfMonth();