<?php $y = "2003"; $m = "5"; $d = strtotime("$y-$m-1"); // 該月開始 $e = strtotime("$y-$m-".date("t",$d)); //該月結束 //驗證 echo date("Y-m-d",$d); echo date("Y-m-d",$e); ?>php