Jump to content
Fórum Script Brasil
  • 0

Conversão De Datas - Javascript

Fabiano Campos


Olá, galera.

Tenho a seguinte situação: Preciso calcular a dif de dias entre duas datas. A estrutura para o cálculo está ok, porém ele pega o formato de data mm/dd/yyyy.

Eu preciso calcular no formato dd/mm/yyyy. Estou calculando da seguinte forma:

//### Cálculo automático de diárias HOTEL NAC ###
function diasDecorridosHotelNac(){

    var dataCheckin  = window.document.getElementById("subviewHotel:data_checkin").value;
    var dataCheckout = window.document.getElementById("subviewHotel:data_checkout").value;
    var pDataCheckin = new Date (dataCheckin);
      var pDataCheckout = new Date (dataCheckout);
      var difDias = Math.abs(Math.round((pDataCheckout-pDataCheckin)/86400000));

      window.document.getElementById("subviewHotel:qtdDiarias").value = difDias;

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Forum Statistics

    • Total Topics
    • Total Posts
  • Create New...