I have a Challenge
object, which has it\'s own properties and I\'m able to add it to the database successfully like this:
DocumentReference chal
In kotlin we need to define an initialized data class to send the whole object to Firestore, make sure that you add your @ServerTimeStamp
in the last field, since if you add it at first, the construction of your object will need to pass this time as a value to your Object instance.
data class Order(val orderId:String, val cart:MutableList, @ServerTimeStamp timestamp:Date? = null)
Create your object and send the object values to Firestore
val order = Order("kJKLkj259ajHHkl",cartList)
FirebaseFirestore.getInstance().collection("orders").add(order)...
This will create your object with orderId, cartlist and also the timestamp which will be stored as
In my case I'm from Argentina, and the date picked up from my app was this one
timestamp: 30 de marzo de 2020, 10:12:43 UTC-3
You can find more about date formats here and here