Skip to content

Instantly share code, notes, and snippets.

@MattSandy
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattSandy/0b43f602e69e09e86aff to your computer and use it in GitHub Desktop.
Save MattSandy/0b43f602e69e09e86aff to your computer and use it in GitHub Desktop.
Return Date Range Array
<?php
function createDateRangeArray($startDate,$endDate)
{
$range[0] = $startDate;
$startDateInt = preg_replace('/[^0-9]/', '', $startDate);
$endDateInt = preg_replace('/[^0-9]/', '', $endDate);
if($endDateInt>$startDateInt)
{
while($range[count($range)-1]!=$endDate)
{
list($year,$month,$day) = explode("-",$range[count($range)-1]);
$range[count($range)] = date("Y-m-d", mktime(0, 0, 0, $month, $day+1, $year));
}
}
return $range;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment