Question: I'm trying to retrieve the month using `date`.

```
$year= 2012;
$mon = date( 'F', mktime(0, 0, 0, $month,$year) );

```

In the above code snippet, `$month` is dynamically incremented. I have used a while loop with `$month++`. But it doesn't give me the correct date.

For example, let's say I gave `$month=5` at the beginning, then it's incremented till `$month=12`. Then the output should be something like

```
May
June
July... 

```

but, it's output is:

```
November
December
January.....

```

why is this? Am I doing anything wrong here?

Answer: 
You forgot $date parameter. THe correct syntax of mktime is 

```
mktime($hour,$minute,$second,$month,$day,$year);

```

so in your example $year will be considered as 'date'

try something like

```
mktime(0,0,0,$month,1,$year);

```
Your problem stems from these lines:

```
$year= 2012;
$mon = date( 'F', mktime(0, 0, 0, $month,$year) );

```

To be exact from the mktime command. The exact syntax is: mktime($hour,$minute,$second,$month,$day,$year);

As you have given $year as 5th parameter it is interpreted as "day" instead of "year". Thus when you set the month to 5 you get month 5 +2012 days which means the 1st day of may is incremented by 2011 days and that results in november then.

You should use the following line instead to get the desired result:

```
$mon = date( 'F', mktime(0, 0, 0, $month,1,$year) );

```

That way you get the desired month (and the day is always the first of this month....so it does not interfere with your calculation.