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

142
Vistas
firebase Functions TimeStamp convert it to string
const signupTime =admin.database.ServerValue.TIMESTAMP
    
    database.ref(`/admin/vendorOrder/${vendor}/${userID}`).set(signupTime);
    console.log(signupTime);

i want the time value while in database it returns correctly enter image description here

in consol log it returns enter image description here

how do i make it return value in string

also

database.ref(`/admin/vendorOrder/${vendor}/${userID}/${signupTime}/order`).set(order);

returns error enter image description here kindly help

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

0

As explained in the doc, with ServerValue.TIMESTAMP you get "a placeholder value for auto-populating the current timestamp as determined by the Firebase servers".

In other words signupTime does not contain the value of the timestamp, since this one is set on the server (the back-end) when you write to the database.

If you want to get this value in your Cloud Function (or in a front-end), you need to query the newly set database node, as follows, for example:

  const signupTime = admin.database.ServerValue.TIMESTAMP

  const database = admin.database();
  const ref = database.ref(`/admin/vendorOrder/${vendor}/${userID}`);

  ref
    .set(signupTime)
    .then(() => {
      return ref.get();
    })
    .then((snap) => {
      console.log(snap.val());
    })
    .catch((error) => {
      console.log(error);
    });
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