首页 > 编程知识 正文

PHP指定日期获取月份

时间:2023-05-04 06:08:18 阅读:8667 作者:3129

//code
functiongetMonthsInRange($startDate,$endDate){
$months=array();
while(strtotime($startDate)<=strtotime($endDate)){
$month=date('Y',strtotime($startDate))."-".date('M',strtotime($startDate));
array_push($months,$month);
$startDate=date('dMY',strtotime($startDate.'+1month'));
}

return$months;
}


版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。