Home > php教程 > php手册 > php获取指定月的某一天的日期

php获取指定月的某一天的日期

WBOY
Release: 2016-06-07 11:45:04
Original
1427 people have browsed it

php获取指定月的某一天的日期
   /**<br>       * 获取指定月的第几天的日期<br>       * @$year 年,$month月,$day天,$format显示时间的格式,$last是否该月最后一天<br>       * @return $str<br>       */<br> function getMonthDay($year,$month,$day,$format='Y-m-d',$last=0){<br>         if($last){<br>             $time=new DateTime($day);        <br>             $d=strtotime($time->format("Y-m-d"));<br>             $d=date("t",$d);<br>             $time->setDate($year,$month,$d);<br>         }else{<br>             $time=new DateTime();<br>             $time->setDate($year,$month,$day);<br>         }<br>         return $time->format($format);<br>     }如要获取2013年3月第一天,getMonthDay(2013,3,1)返回:2013-03-01
如要获取2013年最后一天,getMonthDay(2013,2,'',1)返回2013-02-28

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template