Problems in Javascript date conversion

Asked

Viewed 54 times

0

I have a system hosted at UOL where I capture the data through a ajax of my WebService and the dates that are in the bank are in the format of DD/MM/AAAA but when I return to the screen(HTML) the dates are eventually converted to MM/DD/AAAAA.

There’s a way I can always form in the form DD/MM/AAAAA?

Follow the code @Lucas Costa

I seek information from WS Try{ //Request on Server $. ajax({ type: "POST",
url: method, data: JSON.stringify(parameters),

        beforeSend: function(){
            loading.css('visibility', 'visible'); // exibe o div
        },
        complete: function(){
            loading.css('visibility', 'hidden'); // esconde o div
            divLoading.classList.remove('loading');
            divLoading.innerHTML = '';
        },

        cache: false,
        contentType: "application/json", //; charset=utf-8",
        dataType: "json",
        success: function (resposta) {
            if (resposta.d !== null && resposta.d !== "") {
                pagina = 0;                
                dados  = resposta.d;                 
            }  

**Then I populate my table

for (var i = 0; i < data.length; i++){ cont ++; tbody.append(
$("")

            .append($("<td title='Status de viagem: " + dados[i].DscStatus + "'>")
            .append("<button type='button' "+
            "class='btn btn-default btn-sm' onclick='javascript: AbrirRegistroDadosVaigem(" + dados[i].NroViagem + ");'> "+
            "<span class='glyphicon glyphicon-road' style='color:" + dados[i].CorStatus +";'></span></button>"))

            .append($("<td>").append("<button type='button' class='btn btn-primary btn-sm'  data-toggle='modal' data-target='#myCheckList'" +
            " onclick='javascript: AbrirCheckList(" + dados[i].NroViagem + ");'> " +
            "<span class='glyphicon glyphicon-list'></span></button>"))

            .append($("<td>").append("<button type='button' class='btn btn-primary btn-sm' " +
            " onclick='javascript: AbrirRegistroFup(" + dados[i].NroViagem + ");'> " +
            "<span class='glyphicon glyphicon-envelope badge'> " + dados[i].QtdFup + " </span></button>"))

            .append($("<td>").append("<input type='checkbox' value=''>"))                        
            .append($("<td>").append(dados[i].DataColeta))
            .append($("<td>").append(dados[i].DataEntrega))   

And the problem is the Date Collection and Date Delivery fields that are now DD/MM/YYYY and sometimes MM/DD/YYYY

  • 2

    Could include code instead of image?

1 answer

0


Javascript has its own standard of dates, so you need to convert them.

See here, this answer solves your problem:

/a/6535/5126

  • Paul already tried the problem is that now the date comes as DD/MM/YYYY and sometimes comes as MM/DD/YYYY. I have already tried to contact the support of UOL and they inform that it does not have this type of condition in IS

  • Well, I had a problem like that, it wasn’t in Javascript, but maybe it’s the same thing. The server was configured with the English language, my Portuguese PC. I configured the server for Portuguese. It turns out that every time I went up my site, the server would crash and I would only notice it after a client called complaining... Check to see if there’s no way to LOCALLY define the version of your site. on ASP.NET is possible to do this on web.config, so regardless of the server language setting, it is possible to keep it in Portugese with the right date.

  • Great. I’ll try that’s feedback. Thank you.

Browser other questions tagged

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