function
getDateFromRange(
$startdate
,
$enddate
){
$stimestamp
=
strtotime
(
$startdate
);
$etimestamp
=
strtotime
(
$enddate
);
$days
= (
$etimestamp
-
$stimestamp
)/86400+1;
$date
=
array
();
for
(
$i
=0;
$i
<
$days
;
$i
++){
$date
[] =
date
(
'Y-m-d'
,
$stimestamp
+(86400*
$i
));
}
return
$date
;
}
echo
'<pre>'
;
$date
= getDateFromRange(
'2018-12-25'
,
'2019-01-05'
);
print_r(
$date
);
function
showMonthRange(
$startdate
,
$enddate
)
{
$end
=
date
(
'Y-m'
,
strtotime
(
$enddate
));
$range
= [];
$i
= 0;
do
{
$month
=
date
(
'Y-m'
,
strtotime
(
$startdate
.
' + '
.
$i
.
' month'
));
$range
[] =
$month
;
$i
++;
}
while
(
$month
<
$enddate
);{
return
$range
;
}
}
$range
= showMonthRange(
'2018-12'
,
'2019-02'
);
echo
'<pre>'
;
print_r(
$range
);
留言列表