How do I get the name of the month in an input type = month?

-1

I have a code that has an input of type month that generates a calendar with the values passed in the input, however it saves the values in this standard 2000-12, and I want to display the name of the month on the calendar but not is it possible because the month is passed in digits, is there any way to get the values directly from the input?

<body>
        
        <?php
        
        $datee = explode('-', $_POST['datac']);
        $mes = $datee[1];
        $ano = $datee[0];
        $ultimo_dia = date("t", mktime(0,0,0,$mes,'01',$ano));
        if ($mes == date('m')){
            $dias = $ultimo_dia;
        }elseif ( $mes == '') {
            $mes = date('m');
            $ano = date('o');
            $dias = $ultimo_dia;
        }else{
            $dias = $ultimo_dia;
        }
    

            ?>
            <?php
            echo '<h4>'.$mes. ' de ' .$ano.'</h4>';
            ?>
    
            <form method="post" action="date.php">
                <input type="month" name="datac" value="<?php echo $ano?>-<?php echo $mes?>" required><input type="submit">
                <table class="table table-striped" width="210" border="2" cellspacing="4" cellpadding="4">
                    <tr>
                        <td width="80px"><center>Domingo</center></td>
                        <td width="80px"><center>Segunda</center></td>
                        <td width="80px"><center>Terça</center></td>
                        <td width="80px"><center>Quarta</center></td>
                        <td width="80px"><center>Quinta</center></td>
                        <td width="80px"><center>Sexta</center></td>
                        <td width="80px"><center>Sábado</center></td>
                    </tr>
                    <?php
                    echo "<tr>";
                    for ($i = 1; $i <= $dias; $i++) {
                        $diadasemana = date("w", mktime(0, 0, 0, $mes, $i, $ano));
                        $cont = 0;
                        if ($i == 1) {
                            while ($cont < $diadasemana) {
                                echo "<td></td>";
                                $cont++;
                            }
                        }
                        echo "<td width='100px' height='100px'><center>";
                        echo $i;
                        echo "</center></td>";
                        if ($diadasemana == 6) {
                            echo "</tr>";
                            echo "<tr>";
                        }
                    }
                    echo "</tr>";
                    ?>
            </table>
                
    
                    </form>
                    </body>
                    </html>
    
asked by anonymous 10.06.2016 / 15:41

1 answer

2

Below I'll cite some possible ways = >

    <?php
    ############################################################
    ############## Essas configurações podem ser settadas no seu servidor Web
    ###########################################################
    setlocale(LC_ALL, "pt_BR", "pt_BR.iso-8859-1", "pt_BR.utf-8", "portuguese");
    date_default_timezone_set('America/Sao_Paulo');


    $getMonthNum = 06;
    ############################################################

    echo strftime("%B", strtotime(date("Y-{$getMonthNum}-d")));

    ############################################################
    echo '<br>';
    $dateObj = DateTime::createFromFormat('!m', $getMonthNum);
    $mes = $dateObj->format('F');

    echo strftime('%B', $dateObj->getTimestamp());

    ##############################################################
    echo '<br>';
    $meses = array(1 => "Janeiro", 2 => "Fevereiro", 3 => "Março", 4 => "Abril", 5 => "Maio", 6 => "Junho",
        7 => "Julho", 8 => "Agosto", 9 => "Setembro", 10 => "Outubro", 11 => "Novembro", 12 => "Dezembro");

    echo $meses[$getMonthNum];

Something else, instead of using <center> , use style="text-align:center" . Because <center> is already DEPRECATED in HTML5

    
10.06.2016 / 18:51