Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

215
Visualizações
Date getSeconds returns 0 when subtracting to another Date getSeconds
function returntime() {
  var start = new Date().getSeconds();
  var end = new Date().getSeconds();
  var totaltime = end - start;
  document.getElementById("Answer").innerHTML = totaltime;
}

The totaltime return 0 but when i put start or end it shows the output.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

There is no delay between both statements.

var start = new Date().getSeconds();
  var end = new Date().getSeconds();

See this image for debugger output

about 4 years ago · Juan Pablo Isaza Relatório

0

You ask for seconds. The code runs faster than a second. For example, you get 9 seconds at the start and 9 seconds in the end. If you ask for the milliseconds you will see that you will have a different result.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda