Skip to content

Instantly share code, notes, and snippets.

@hasokeric
Created July 10, 2015 18:38
Show Gist options
  • Save hasokeric/c8e07c87562202328474 to your computer and use it in GitHub Desktop.
Save hasokeric/c8e07c87562202328474 to your computer and use it in GitHub Desktop.
PHP Get Quarterly Date Start and End
function get_quarter_dates_array($quarter)
{
$date_start = "%Y-01-01";
$date_end = "%Y-03-31";
switch ($quarter)
{
case 1:
$date_start = "%Y-01-01";
$date_end = "%Y-03-31";
break;
case 2:
$date_start = "%Y-04-01";
$date_end = "%Y-06-31";
break;
case 3:
$date_start = "%Y-07-01";
$date_end = "%Y-09-31";
break;
case 4:
$date_start = "%Y-10-01";
$date_end = "%Y-12-31";
break;
default:
break;
}
return ['start' => $date_start, 'end' => $date_end];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment