Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

137
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!