Skip to content
Advertisement

Birthdate values in php html

Good day everyone I have a little problem with this code. All of my month values are “January”. Any help would be very much appreciated, thank you.

Birthday: 
<select name="month">
<option value="0">Select Month</option>
<?php
    for( $m = 1; $m <= 12; $m++ ) {
        $num = str_pad( $m, 2, 0, STR_PAD_LEFT );
        $month = date( 'F', mktime( 0, 0, 0, $m + 1, 0, 0, 0 ) );
        ?>
            <option value="<?php echo $num; ?>"><?php echo $month; ?></option>
        <?php
    }
?>
</select>

Advertisement

Answer

$month = date( ‘F’, mktime( 0, 0, 0, $m + 1, 0, 0 ) );

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement