Skip to content

Instantly share code, notes, and snippets.

@andejoni89
andejoni89 / splitByMonths.php
Last active March 2, 2025 17:30 — forked from zashme/splitByMonths.php
split date range into months ranges
<?php
function getMonthRanges($start, $end)
{
$timeStart = strtotime($start);
$timeEnd = strtotime($end);
$out = [];
$milestones[] = $timeStart;
$timeEndMonth = strtotime('first day of next month midnight', $timeStart);
while ($timeEndMonth < $timeEnd) {