I am trying to set a start date and end date by the quarter.
For example, I am working on a reporting system where i need to report data for quarter 1, quarter 2, qu
$monthsFromStart = (date('n') - 1) % 3; // 0, 1, 2, 0, 1, 2, ... $monthsToEnd = 2 - $monthsFromStart; // 2, 1, 0, 2, 1, 0, ... $startDay = new DateTime("first day of -$monthsFromStart month midnight"); $endDay = new DateTime("last day of +$monthsToEnd month midnight");