- /**
- * Get the timestamp of the first day of the specified month and the end of the last day
- *
- * @param int $y year $m month
- * @return array (start time of this month, end time of this month)
- */
- function mFristAndLast($y="",$m=""){
- if($y=="") $y=date("Y");
- if($m=="") $m=date("m");
- $m=sprintf("%02d",intval($m));
- $y=str_pad(intval($y),4,"0",STR_PAD_RIGHT);
-
- $m>12||$m<1?$m=1:$m=$m;
- $firstday=strtotime($y.$m."01000000");
- $firstdaystr=date("Y-m-01",$firstday);
- $lastday = strtotime(date('Y-m-d 23:59:59', strtotime("$firstdaystr +1 month -1 day")));
- return array("firstday"=>$firstday,"lastday"=>$lastday);
- }
复制代码
|