Input type datetime error

2

Good afternoon, I have a problem that I can not solve, I wanted to change the format of my form to "datetime", but when I test in my browser it appears as if it were text.

<div class="form-group">
    <label>Data de requisicao</label>
    <input type="datetime" class="form-control" name="data" required><br>
<div class="form-group">

    
asked by anonymous 30.01.2018 / 18:49

4 answers

2

By the image classes you posted I noticed that you are using Boostrap . So I suggest this input date template with a datapicker

Need this script to work, as it creates a campo de data in a input text

<script src='http://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.1/js/bootstrap-datepicker.min.js'></script>
<script>
 $('.input-group.date').datepicker({format: "dd.mm.yyyy"});
</script>

<link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
    

          <div class='col-md-3'>
            <div class="form-group">
                <label for="data-pagamento">Datapicker novo</label>
                <!-- Datepicker as text field -->         
                <div class="input-group date" data-date-format="dd.mm.yyyy">
                  <input  type="text" class="form-control" placeholder="dd.mm.yyyy">
                  <div class="input-group-addon" >
                    <span class="glyphicon glyphicon-th"></span>
                  </div>
                </div>
            </div>
          </div>

    
    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

    <!-- Plugin pro Datapicker novo -->
    <script src='https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.1/js/bootstrap-datepicker.min.js'></script>
    <script>
     $('.input-group.date').datepicker({format: "dd.mm.yyyy"});
    </script>
    

    
30.01.2018 / 20:05
2

You should use some of these types:

<input type="datetime-local" name="bdaytime">

or

<input type="date" name="bday" >
  • email
  • datetime-local
  • source: link

        
    30.01.2018 / 18:59
    2

    The input type="date-time" tag has been discontinued:

    link

    And was replaced by the input type="datetime-local" tag:

    link

    document.getElementById("datetime").defaultValue = new Date().toLocaleDateString();
    <html>
    <body>
     <input id="datetime" type="datetime-local">
    </body>
    </html>

    Note: Does not work in IE and Firefox: Chrome OK; Opera OK;

    The type input type="date" is supported in firefox from version 57.0, in Chrome since 22;

    document.getElementById("datetime").value = new Date().toLocaleDateString();
    <html>
    
    <body>
      <input id="datetime" type="date">
    </body>
    
    </html>

    link

      

    Considerations: There are still many inconsistencies in these inputs.    type="datetime-local" DOM properties defaultValue works only in firefox, chromium does not work but DOM properties    value works.

         The type="date" input of the DOM porperties value does not work on   firefox also does not work on Chromium.

    So, did your browser work?

        
    30.01.2018 / 19:09
    0

    According to this article in mozilla the input of type "datetime" is obsolete, and its use is not encouraged:   link

        
    30.01.2018 / 19:01