Imが私にPHPで毎月の日を生成するには?
stdClass Object
(
[data] => Array
(
[1] => 2011-12-1
[2] => 2011-12-2
[3] => 2011-12-3
[4] => 2011-12-4
[5] => 2011-12-5
[6] => 2011-12-6
[7] => 2011-12-7
[8] => 2011-12-8
[9] => 2011-12-9
[10] => 2011-12-10
[11] => 2011-12-11
[12] => 2011-12-12
[13] => 2011-12-13
[14] => 2011-12-14
[15] => 2011-12-15
[16] => 2011-12-16
[17] => 2011-12-17
[18] => 2011-12-18
[19] => 2011-12-19
[20] => 2011-12-20
[21] => 2011-12-21
[22] => 2011-12-22
[23] => 2011-12-23
[24] => 2011-12-24
[25] => 2011-12-25
[26] => 2011-12-26
[27] => 2011-12-27
[28] => 2011-12-28
[29] => 2011-12-29
[30] => 2011-12-30
[31] => 2011-12-31
)
)
私の問題のような出力を提供します。この
$year = date('Y');
$month = date('m');
$dayCount = cal_days_in_month(CAL_GREGORIAN,$month,$year);
for ($i = 1; $i <= $dayCount; $i++)
{
$tree_data->data[$i] = $year."-".$month."-".$i;
}
print "<pre>";
print_r($tree_data);
のように、現在の月の日数を生成しようとしている私は1を取得したいです - 9日のように
2011-12-01, 2011-12-02 etc...
どのようにそのような出力を得るために任意のアイデア?
+1のDateTimeの提案。 – liquorvicar
確かに、非常にchique –
ありがとうたくさん... –