ここでは、私の週の配列です。現在の月年は、私がPHP get number of week for monthから、このリンクをコードを持って、コードの下にPHP現在の月の週の数はPHPを使用してのみ取得
function getWeekDates($date, $start_date, $end_date) {
$week = date('W', strtotime($date));
$year = date('Y', strtotime($date));
$from = date("Y-m-d", strtotime("{$year}-W{$week}+1"));
if ($from < $start_date)
$from = $start_date;
$to = date("Y-m-d", strtotime("{$year}-W{$week}-7"));
if ($to > $end_date)
$to = $end_date;
$array1 = array(
"ssdate" => $from,
"eedate" => $to,
);
return $array1;
}
$mm = date('m');
$yy = date('y');
$startdate = date($yy . "-" . $mm . "-01");
$current_date = date('Y-m-t');
$ld = cal_days_in_month(CAL_GREGORIAN, $mm, $yy);
$lastday = $yy . '-' . $mm . '-' . $ld;
$start_date = date('Y-m-d', strtotime($startdate));
$end_date = date('Y-m-d', strtotime($lastday));
$end_date1 = date('Y-m-d', strtotime($lastday . " + 7 days"));
$count_week = 0;
$week_array = array();
for ($date = $start_date; $date < $end_date1; $date = date('Y-m-d', strtotime($date . ' + 7 days'))) {
$getarray = getWeekDates($date, $start_date, $end_date);
$week_array[] = $getarray;
$count_week++;
}
echo '<pre>';
print_r($week_array);
を試してみました。しかし、何の意味もありません。ここ
、私の週の配列です:
Array
(
[0] => Array
(
[ssdate] => 2017-09-01
[eedate] => 2017-09-03
)
[1] => Array
(
[ssdate] => 2017-09-04
[eedate] => 2017-09-10
)
[2] => Array
(
[ssdate] => 2017-09-11
[eedate] => 2017-09-17
)
[3] => Array
(
[ssdate] => 2017-09-18
[eedate] => 2017-09-24
)
[4] => Array
(
[ssdate] => 2017-09-25
[eedate] => 2017-09-30
)
[5] => Array
(
[ssdate] => 2017-10-02
[eedate] => 2017-09-30
)
)
しかし
Array
(
[0] => Array
(
[sdate] => 2017-09-01
[sdate] => 2017-09-02
[sdate] => 2017-09-03
)
[1] => Array
(
[sdate] => 2017-09-04
[sdate] => 2017-09-05
[sdate] => 2017-09-06
[sdate] => 2017-09-07
[sdate] => 2017-09-08
[sdate] => 2017-09-09
[sdate] => 2017-09-10
)
[2] => Array
(
[sdate] => 2017-09-11
[sdate] => 2017-09-12
[sdate] => 2017-09-13
[sdate] => 2017-09-14
[sdate] => 2017-09-15
[sdate] => 2017-09-16
[sdate] => 2017-09-17
[sdate] => 2017-09-18
)
[3] => Array
(
[sdate] => 2017-09-18
[sdate] => 2017-09-19
[sdate] => 2017-09-20
[sdate] => 2017-09-21
[sdate] => 2017-09-22
[sdate] => 2017-09-23
[sdate] => 2017-09-24
)
[4] => Array
(
[sdate] => 2017-09-25
[sdate] => 2017-09-26
[sdate] => 2017-09-27
[sdate] => 2017-09-28
[sdate] => 2017-09-29
[sdate] => 2017-09-30
)
)
の下にこの問題
を解決するために私を助けてくださいように私は、唯一の現在の月の配列をしたいです前もって感謝します !!!
例えばその2月には、あなたは4週間たい場合は? –
feb月のためにうまくいきます。もしそれがsep、oct、などであれば、それは次の月の日付も私に与えます。私は現在の月の週の日付だけを欲しい。 – Angel
特定の月の日付または週数が必要ですか? –