How to get current timestamp of firebase server in milliseconds?

前端 未结 3 590
[愿得一人]
[愿得一人] 2020-12-15 18:21

I wanted to get firebase current timestamp, not able to find a way to get that. I want to save child as shown in the image. And for that I\'ve to get timestamp and get the d

3条回答
  •  一向
    一向 (楼主)
    2020-12-15 18:32

    Actually, you can use cloud functions, and get the timestamp via an HTTP request. The function is very simple.

    exports.getTimeStamp = functions.https.onRequest((req, res)=>{
      res.setHeader('Content-Type', 'application/json');
      res.send(JSON.stringify({ timestamp: Date.now() }));
    });
    

提交回复
热议问题