0

I'm using Firebase Functions as my server for my app and my functions retrieve some data from my Firestore database and return it to the user. The date variables of objects from the database are always formatted as a string with the format:

"yyyy-MM-dd'T'HH:mm:ss.SSSZZZ"

However, when I retrieve the same objects using the SDK, the dates are now returned as a Firebase Timestamp e.g:

FIRTimestamp: seconds=1520380800 nanoseconds=0>

How can I make the node.js Function code return the dates as a Firebase Timestamp as well?

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Tometoyou
  • 7,792
  • 12
  • 62
  • 108

2 Answers2

0

You can get a Firestore formatted timestamp in Node.js with the following command:

let myTime = new Date().toISOString()
Jason Berryman
  • 4,760
  • 1
  • 26
  • 42
0

The timestamp returned is a UNIX timestamp.

How to convert this to a "normal" datetime is explained here...

Edo Akse
  • 4,051
  • 2
  • 10
  • 21