A php function to get the first and last day of the month, Functions collected online, but this function feels a bit cumbersome to implement. There is also a similar function in the recommended reading in this article, you can also take a look.
<span>/*</span><span>* * 获取指定月份的第一天开始和最后一天结束的时间戳 * * @param int $y 年份 $m 月份 * @return array(本月开始时间,本月结束时间) </span><span>*//*</span><span> 何问起 hovertree.com </span><span>*/</span> <span>function</span> mFristAndLast(<span>$y</span>="",<span>$m</span>=""<span>){ </span><span>if</span>(<span>$y</span>=="") <span>$y</span>=<span>date</span>("Y"<span>); </span><span>if</span>(<span>$m</span>=="") <span>$m</span>=<span>date</span>("m"<span>); </span><span>$m</span>=<span>sprintf</span>("%02d",<span>intval</span>(<span>$m</span><span>)); </span><span>$y</span>=<span>str_pad</span>(<span>intval</span>(<span>$y</span>),4,"0",<span>STR_PAD_RIGHT); </span><span>$m</span>>12||<span>$m</span><1?<span>$m</span>=1:<span>$m</span>=<span>$m</span><span>; </span><span>$firstday</span>=<span>strtotime</span>(<span>$y</span>.<span>$m</span>."01000000"<span>); </span><span>$firstdaystr</span>=<span>date</span>("Y-m-01",<span>$firstday</span><span>); </span><span>$lastday</span> = <span>strtotime</span>(<span>date</span>('Y-m-d 23:59:59', <span>strtotime</span>("<span>$firstdaystr</span> +1 month -1 day"<span>))); </span><span>return</span> <span>array</span>("firstday"=><span>$firstday</span>,"lastday"=><span>$lastday</span><span>); }</span>
Recommended: http://www.cnblogs.com/roucheng/p/phpexcel.html