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

103
Visualizações
timestamp to IST reactjs

How to compare the firebase timestamp with Indian Standard Time (IST). We have to compare everything like date and time. If both are equal we should give a message in alert box as Success otherwise alert as not-matchedThis is the image of firebase timestamp

This is the image for IST date

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

0

You can convert the firestore timestamp to javascript timestamp using .toDate() and then convert the js timestamp to the desired timezone - you can use sophisticated moment-timezone library method moment().tz() or the js date library method toLocaleString().

fbTs.toDate().toLocaleString(undefined, { timeZone: 'Asia/Kolkata' }); 

fbTs is the firestore timestamp

For comparison, it is better to convert both the timestamps - the firebase timestamp and the current timestamp in epoch timestamp and compare. getTime() method will get you this. `

if (fbTs.toDate().getTime() === new Date().getTime()) { 
  ...
} else { 
  ...
}

about 4 years ago · Juan Pablo Isaza Relatório

0

Fetch the date from firebase, and call Date.parse() on it to convert it to an epoch date. Then do the same on your IST date. If you want the current time in an epoch date use Date.now().

Something like this:

const updatedDateEpoch = Date.parse(*YOUR DATE FROM FIREBASE*)

// if you want the current time use this date
const currentEpoch = Date.now()

// IST date to epoch
const istEpoch = Date.parse(*THE IST DATE YOU HAVE*)

// switch currentEpoch to istEpoch if you don't want to use the current time.
if (currentEpoch === updatedDateEpoch){
    alert("Success!")
}else{
    alert("Not matched.")
}
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