input date Html5

Asked

Viewed 9,997 times

1

I’ve been looking for Html5 settings for the date attribute to display the date in the format we used in Brazil (dd/mm/yyyy), but it doesn’t seem to have any extra settings for this. In some tutorials the default format is already this, but my calendar is displayed in the default yyyy/mm/dd. Any solution for this?

<html>
<head>
    <meta charset="UTF-8">
</head>
<body oncontextmenu='return false' onselectstart='return false' ondragstart='return false'>  <!-- Não deixa o usuário clicar com o botão direito na página -->
    <div class="container clearfix">
        <?php
            include "header.php";
        ?>
            <div class="conteudo_painel">
                <h1>Painel do Cliente - <?php echo $_SESSION['nome_cliente']; ?></h1> <!-- Nome do cliente para mostrar no painel -->
                <!-- Div sobre o boleto -->
                    <div class="segunda_via">
                        <h2>2ª via do boleto</h2>
                        <h4>Escolha a data que efetuará o pagamento:</h4>
                        <form method="post" action="?acao=confirmar">
                            </br><input type="date" id="data" name="data" maxlength="10" size="" OnKeyPress=" formatar('##/##/####', this)">
                            </br><input type="image" src="img/gera_boleto.png" value="Confirmar" id="gera_boleto">
                        </form>
                    </div>
                    <?php
                        } else { //caso o boleto não tenha vencido e o cliente não tenha pago, mostra o boleto primeira via
                    ?>
                        <div class="boleto_itau" >
...

O chrome exibe no formato br e o safari no norte americado

  • 1

    Read here http://stackoverflow.com/questions/7372038/is-there-any-way-to-change-input-type-date-format

  • I tried it here in the Brazilian standard. Have a look here. http:/jsfiddle.net/Ls8gxzk7/

  • Hello, Try this way using the jQuery UI library: Example: http://jsfiddle.net/uLnrd6pu/

1 answer

1

Try this:

<!DOCTYPE html>
<html lang="pt-BR">
<head>
    <meta charset="UTF-8" />
</head>

Here is an example using the en datepicker, where it is available at: link github jquery.ui.datepicker-en-BR.js

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>teste</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">    </script>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
    <script src="datepicker-pt-BR.js"></script>
    <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
    <script>
        $(function() {
            $( "#datepicker" ).datepicker();
        });
   </script>
</head>
<body>

<p>Data: <input type="text" id="datepicker"></p>

</body>
</html>
  • In my tests here, in the browsers webkit (Chrome, Safari, Maxthon and the like) the date format corresponds to the format defined in the operating system and even putting the attribute lang="pt-BR" (tried in the tags <html>, <body> and in itself <input>) the format did not comply with the Brazilian standard. In Firefox and IE (11) input[type=date] behaves like a normal text input.

  • I use safari to test the visualization of ipad and iphone, in it the format is in English, but in Chrome is in Portuguese. Must be some configuration of his Webkit then...

  • Perhaps it would be interesting to see a datepicker component of the Portuguese jqueryui.

    • Configure the datepicker component of jqueryui in English.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.