Skip to content

Instantly share code, notes, and snippets.

Created January 12, 2015 12:07
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 anonymous/c1dc49c23ddc0813a156 to your computer and use it in GitHub Desktop.
Save anonymous/c1dc49c23ddc0813a156 to your computer and use it in GitHub Desktop.
$dates = array(
'2014-08','2014-09','2014-11','2014-12','2015-02');
function InactiveMonths($dates) {
sort($dates);
$start = min($dates);
$stop = max($dates);
list($firstYear,$firstMonth) = explode('-',$start,2);
list($lastYear,$lastMonth) = explode('-',$stop,2);
$m = $firstMonth;
for($y=(int)$firstYear;$y<=(int)$lastYear;$y++) {
while(($y<$lastYear&&$m<=12) || ($y==$lastYear&&$m<=$lastMonth)) {
$YM = sprintf('%d-%02d',$y,$m);
echo $YM.' '.(in_array($YM,$dates)?'Active':'Inactive').'<br />';
$m++;
}
$m = 1;
}
}
InactiveMonths($dates);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment