Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

102
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda