0

Trying to find out the new way to show a timestamp in collections, usually it just used to be

timestamp: firebase.firestore.FieldValue.serverTimestamp()

im using the timestamp key aswell if that changes anything, I cannot find it anywhere, apparently they updated it as there was an issue?

db.collection('posts').add({
              message: input,
              timestamp: firebase.firestore.FieldValue.serverTimestamp(),
              profilePic: user.photoURL,
              username: user.displayName,
              image: image,
            })

Thanks

Nathan
  • 1
  • 3
  • "apparently they updated it as there was an issue?" This is impossible to help with. Please show [what you tried that doesn't work](http://stackoverflow.com/help/mcve), or link to the source that caused your confusion. – Frank van Puffelen Jan 14 '21 at 02:29
  • ive edited as above, this does not work anymore and they have updated it , then in this thread https://stackoverflow.com/questions/46913824/is-there-any-way-to-use-fieldvalue-servertimestamp-in-firebase-firestore-js-wi they explained to use Firebase.ServerValue.TIMESTAMP none of them work , neither does this https://firebase.google.com/docs/reference/node/firebase.firestore.FieldValue – Nathan Jan 14 '21 at 02:40
  • "this does not work anymore" Why not? What is the problem when you run this code? Is there an error message? Did you compare it to the documentation? https://firebase.google.com/docs/firestore/manage-data/add-data#server_timestamp – Frank van Puffelen Jan 14 '21 at 04:16
  • yes exactly the error is Cannot read property 'FieldValue' of undefined – Nathan Jan 14 '21 at 04:26
  • So can you show how you import `firebase`? Essentially: we need to be able to copy/paste your code into a file of our own and reproduce the problem. I highly recommend checking out [how to create a minimal, complete, verifiable example](http://stackoverflow.com/help/mcve), as following the guidance in there drastically increases the chance that we can help. – Frank van Puffelen Jan 14 '21 at 04:30
  • you wont believe it, all had to do was change import firebase from "firebase" instead of "./firebase". thanks anyway mate cheers – Nathan Jan 14 '21 at 04:31

0 Answers0