1

@startdate と @enddate の 2 つのパラメーターを持つストアド プロシージャがあります。

そして、私は以下のようなURLを持っています

'http://localhost/filename.php?startdate='01-08-2012'&enddate='31-08-2012'

現状では、毎月これを手動で変更して、今月の開始日と終了日を取得する必要があります。たとえば、9 月の場合、'01-09-2012' '31-09-2012' を変更する必要があります。

毎月の最初の日を開始日として、その月の最後の日を URL の終了日として自動的に取得する PHP コードまたは関数を探していますか?

4

2 に答える 2

4

初日:

date('Y-m-01'); //current year and month

最終日:

date("Y-m-t"); //current year and month and t means the last day of this month

必要に応じてフォーマットを変更します。

于 2012-08-23T07:15:27.047 に答える
2

前月の最初と最後の日:

$current_year = date('Y');
$current_month = date('m');
$lastdateofmonth = date('t', $current_month);
$startdate = "01-$current_month-$current_year";
$enddate = "$lastdateofmonth-$current_month-$current_year";
于 2012-08-23T07:18:23.027 に答える