<?php
function translateTimr($begin,$end){
$brr = explode('-',$begin);
$err = explode('-',$end);
$arr = [];
if($err[0]-$brr[0] == 0)
{
$num = $err[1]-$brr[1]+1;
}else if($err[0]-$brr[0] == 1){
$num = 12-$brr[1]+1+$err[1];
}else{
$num = 12*($err[0]-$brr[0])-$brr[1]+$err[1];
}
if($brr[0] == $err[0] && $brr[1] == $err[1])
{
$days = date('t', strtotime($begin));
for($i = 1 ; $i <= $days ; $i++)
{
if(strtotime($begin.'-'.$i) == strtotime(date('Y-m-d',time()))){
break;
}
array_push($arr,$begin.'-'.$i);
}
}else{
for($i = 0 ; $i < $num; $i++)
{
$month = date('m',strtotime($begin));
$year = date('Y',strtotime($begin));
$month = $month+$i;
if($month > 12)
{
if($month%12 == 0)
{
$year = $year + floor($month/12-1)*1;
$month = $month-12*(floor($month/12)-1);
}else{
$year = $year + floor($month/12)*1;
$month = $month-12*floor($month/12);
}
}
array_push($arr,$year.'-'.$month);
}
}
return $arr;
}
?>
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号