user142019
user142019

Reputation:

PHP's date always returns January?

I'm writing a sign up form, and I have this:

<?php
for($j = 1; $j <= 12; $j++)
{
    $month = date("F", mktime(0, 0, 0, j, 1, 2000));
    echo '<option value="'.$month.'">'.$month.'</option>';
}
?>

The problem is that my select box shows 'January' 12 times, but I want January, February, March etc... through December. How can I fix this? Thanks.

Upvotes: 0

Views: 391

Answers (5)

dnagirl
dnagirl

Reputation: 20446

syntax error? j needs a $:

$month = date("F", mktime(0, 0, 0, $j, 1, 2000));

Upvotes: 1

Ben Everard
Ben Everard

Reputation: 13804

Should it be

mktime(0, 0, 0, $j , 1, 2000));

$j instead of j

Upvotes: 1

erenon
erenon

Reputation: 19118

It's $j.

$month = date("F", mktime(0, 0, 0, $j, 1, 2000));

Upvotes: 1

Doug T.
Doug T.

Reputation: 65639

Do you mean

$month = date("F", mktime(0, 0, 0, $j, 1, 2000));

Notice the $ on the j

Upvotes: 1

Palantir
Palantir

Reputation: 24182

You are missing a dollar sign in front of "j" here:

$month = date("F", mktime(0, 0, 0, j, 1, 2000));

Upvotes: 5

Related Questions