php获取一个月的第一天和最后一天

jerry thinkphp 2015年11月19日 收藏
用php来获取一个月的第一天和最后一天,最近要开放任务系统,在某个地方看到的,记录一下,分享给大家,不喜勿喷!
  1. //调用demo
  2. $date = date('Y-m-d H:i:s'); //当前时间
  3. print_r(getthemonth($date));

  4. function getthemonth($date)
  5. {
  6.     $firstday = date('Y-m-01', strtotime($date));
  7.     $lastday = date('Y-m-d', strtotime("$firstday +1 month -1 day"));
  8.     return array($firstday, $lastday);
  9. }