How to save previous timestamp to Firebase FireSto

2019-07-05 03:27发布

I want to migrate the older data from different system to firestore.

below command saves current timestamp

firebase.firestore.FieldValue.serverTimestamp()

I want to store older values, Is there any way available?

1条回答
Viruses.
2楼-- · 2019-07-05 03:52

firebase.firestore.FieldValue.serverTimestamp() is a marker value you can use in your code to write the current server-side timestamp into a date field. If you want to store another value in a date field, you can specify the value when writing.

From the Firebase documentation on adding data:

db.collection("data").doc("one").set({
    dateField: new Date("December 10, 1815"),
}).then(function() {
    console.log("Document successfully written!");
});
查看更多
登录 后发表回答