Get all days and date for a given month

arrays, date, php

Solution

try this

$list=array();
$month = 12;
$year = 2014;

for($d=1; $d<=31; $d++)
{
    $time=mktime(12, 0, 0, $month, $d, $year);          
    if (date('m', $time)==$month)       
        $list[]=date('Y-m-d-D', $time);
}
echo "<pre>";
print_r($list);
echo "</pre>";

Problem

Would like to retrieve all days and date for a given month. Have this currently which shows all the days for the current month, but how do I parse in a specified month instead? ``` $list=array(); for($d=1; $d<=31; $d++) { $time=mktime(12, 0, 0, date('m'), $d, date('Y')); if (date('m', $time)==date('m')) $list[]=date('Y-m-d-D', $time); } echo "<pre>"; print_r($list); echo "</pre>"; ```

Original source