function currentMonth($time)
{
$info['start'] = strtotime(date( 'Y-m-1 00:00:00', $time ));
$mdays = date( 't', $time );
$info['end'] = strtotime(date( 'Y-m-' . $mdays . ' 23:59:59', $time ));
return $info;
}
function lastMonth($time)
{
$datetime = date('Ymd',$time);
$info['start'] = strtotime(date("Y-m-1 00:00:00",strtotime("last months",strtotime($datetime))));
$mdays = date( 't', $time );
$info['end'] = strtotime(date( 'Y-m-' . $mdays . ' 23:59:59', $info['start']));
return $info;
}
function nextMonth($time){
$arr=getdate($time);
if($arr['mon'] == 12){
$year=$arr['year'] +1;
$month=$arr['mon'] -11;
$firstday=$year.'-0'.$month.'-01';
$lastday=date('Y-m-d',strtotime("$firstday +1 month -1 day"));
}else{
$firstday=date('Y-m-01',strtotime(date('Y',$time).'-'.(date('m',$time)+1).'-01'));
$lastday=date('Y-m-d',strtotime("$firstday +1 month -1 day"));
}
$info['start'] = $firstday;
$info['end'] = $lastday;
return $info;
}
function lastYearMonth($time)
{
$info['start'] = strtotime(date( 'Y-m-01 00:00:00', strtotime("-1 years",$time) ));
$mdays = date( 't', $time );
$info['end'] = strtotime(date( 'Y-m-' . $mdays . ' 23:59:59', strtotime("-1 years",$time) ));
return $info;
}
function currentYear($time)
{
$info['start'] = strtotime(date( 'Y-01-01 00:00:00', $time ));
$info['end'] = strtotime(date( 'Y-12-31 23:59:59', $time ));
return $info;
}
function lastYear($time)
{
$info['start'] = strtotime(date( 'Y-01-01 00:00:00', strtotime("-1 years",$time) ));
$info['end'] = strtotime(date( 'Y-12-31 23:59:59', strtotime("-1 years",$time) ));
return $info;
}
function allMonth($params,$k=0)
{
$mouth = array();
$start = (date( 'Y-m', $params['startTime'] ));
$end = (date( 'Y-m', $params['endTime']));
if($start <= $end){
$mouth[$k] = $end;
$params['endTime'] = strtotime(date( 'Y-m', strtotime("last months",$params['endTime'])));
$mouth = array_merge($mouth,allMonth($params,$k+1));
}
return $mouth;
}