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

260
Visualizações
Casting string time to timestamp for calculation of date time difference?

I have data coming from an API which formats what should be a datetime object as a string. So the format is: "2021-04-22 19:32:00".

I have a start date and end date in this format.

Since it's a string, using JavaScript to pull out the hours isn't challenging, but I'm wondering, now that I have my two string variables of a theoretical begin and end time, how do I calculate how difference in these two parameters.

Meaning:

object 1 start time would be : "18:30:00". object 2 end time would be : "20:00:00".

And I want to know that difference is 90 minutes...

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

0

for this to work in safari you need to add a T to the middle to create a valid date

console.log(new Date("2021-04-22 19:32:00".replace(/ /,"T")))

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