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 />';
}
#2

[eluser]timj[/eluser]
I was hoping someone might attempt to answer this question. Is it a limitation of the Calendar Helper?




Theme © iAndrew 2016 - Forum software by © MyBB