<?php
function getQuarterEndingOf($month)
{
$quarterEndings = [
1 => 'Mar', 2 => 'Mar', 3 => 'Mar',
4 => 'Jun', 5 => 'Jun', 6 => 'Jun',
7 => 'Sep', 8 => 'Sep', 9 => 'Sep',
10 => 'Dec', 11 => 'Dec', 12 => 'Dec',
];
$timeFormat = sprintf('%s %s',
$quarterEndings[$month],
date('Y')
);
return new \DateTime($timeFormat);
}
var_dump(getQuarterEndingOf(11));
$d = new \DateTime();
var_dump($d->setDate(date('Y'), floor(date('m')/3),date('d')));
preferences:
57.12 ms | 402 KiB | 5 Q