- time: documentation ( source)
- print_r: documentation ( source)
- date: documentation ( source)
- strtotime: documentation ( source)
<?php
function monthToToday($past, $now, $format = 'Y-m') {
$current = strtotime(date('Y-m-1', strtotime($past)));
$result = [];
while($current < $now) {
$result[] = date($format, $current);
$current = strtotime('+1 month', $current);
}
//包含当前月份
$result[] = date($format, $current);
return $result;
}
print_r(monthToToday('2013-12-25', time()));