Convert date from bank in AJAX

0

I would like to convert the date from the bank (2012-02-10) to Brazilian standard (10/02/2012) in the AJAX success example:

 $.ajax({
        type: 'POST',
        dataType: 'json',
        url: "crud/consulta.php",
        data: dados,
        success: function(data) {
            $('.dataFiltro').val(data.data);
            // AQUI ALGUMA CONVERSÃO
});

Or some way to do the conversion in the input of the form, being that, this value will be filled in an input. Any suggestions w

    
asked by anonymous 07.07.2016 / 04:02

2 answers

2

In the case of a datetime field:

<input type="datetime-local" class="dataFiltro" />

You do not need to convert, just concatenate the date with the time:

...
success: function(data) {
    var novaData = data.data;
    novaData = novaData + "T15:35"; //exibirá no formato: 07/07/2016 15:35
    $('.dataFiltro').val(novaData);
}
...
    
07.07.2016 / 14:31
0

You can convert the date into the query and already bring it in the correct format.

    
07.07.2016 / 17:37