Welcome Guest, Not a member yet? Register   Sign In
generate 12 mini-calendars
#1

[eluser]timj[/eluser]
Why doesn't this work? It clearly generates [what appears to be correct when echoed] 12 incremented $this->calendar->generate(Year, month) statements, but every calendar is the default (current) month in the correct year. In other words, it is correctly reading the year and correctly incrementing the month... it is just not reading the month.

More to the point, I guess, is there an easier way to do this?

Code:
function get_months($date1, $date2)
{

$date1 = date('Y-m',strtotime($date1));
$date2 = date('Y-m',strtotime($date2));

if($date1 < $date2)
{
   $past = $date1;
   $future = $date2;
}
else
{
   $past = $date2;
   $future = $date1;
}

$months = array();
for($i = $past; $past<=$future; $i++)
{
   $timestamp = strtotime($past.'-1');
   $months[] = date('Y, m',$timestamp);
   $past = date('Y-m',strtotime('+1 month',$timestamp));  
}

return $months;
}

$this_year = date('Y-m', strtotime('now'));
$next_year = date('Y-m', strtotime('now +12 months'));

$data = get_months($this_year, $next_year);

for($i=0;$i<count($data);$i++)
{
     echo $this->calendar->generate($data[$i]);
     echo 'generate('.$data[$i].')<br />';
}


Messages In This Thread
generate 12 mini-calendars - by El Forum - 11-21-2009, 03:03 PM
generate 12 mini-calendars - by El Forum - 12-05-2009, 03:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB