[php] 2024-04-25 圈点607
摘要:php获取某个日期所在月份的第一天和最后一天的示例代码
php获取某个日期所在月份的第一天和最后一天的示例代码:
function getthemonth($date) { $firstday = date('Y-m-01', strtotime($date)); $lastday = date('Y-m-d', strtotime("$firstday +1 month -1 day")); return array($firstday,$lastday); } $today = date("Y-m-d"); $day=getthemonth($today); echo "当月的第一天: ".$day[0]." 当月的最后一天: ".$day[1];