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

222
Vistas
admin.Firebase.Timestamp stores time 7 hours behind

I'm trying to store a timestamp in Firestore from Firebase Functions. However, the incorrect time is being recorded in Firestore.

For instance, I want to store the UTC time: August 14, 2021 21hr (9pm)

Note: this code is in my Firebase Function

const date = new Date(Date.UTC(
            csvRow.startDateYear,
            csvRow.startDateMonth,
            csvRow.startDateDay,
            csvRow.startDateHour,
            csvRow.startDateMinute
        ))

console.log(date); // prints 2021-08-14T21:00:00.000Z  (correct)

console.log('date.getTime():' + date.getTime()); // prints 1628974800000 (correct)

const timeStamp = admin.firestore.Timestamp.fromMillis(date.getTime());

console.log('timeStamp.toMillis():' + timeStamp.toMillis()); // prints 1628974800000 (correct)

write.startDate = timeStamp;

But when I actually look at the Firestore and see what's recorded, I get this, a timeStamp that's 7 hours behind:

enter image description here

I've also tried Timestamp.fromDate(date) but got the same result

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Firebase Firestore TimeStamps break apart when using hours because they do not have timezones built into them. They are meant to represent a greater period of time, not for specific timezones (hour).

Try this function and see if it works properly:

var myTimestamp = firebase.firestore.Timestamp.fromDate(new Date());

If you are attempting this with Cloud Functions try the following:

admin.firestore.Timestamp.fromDate()

Detailed documentation: https://firebase.google.com/docs/reference/node/firebase.firestore.Timestamp

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