I want to get the date from the Firestore server for consistency, and not from the device. Timestamp(Date()).toDate()
gives time as July 6, 2021 at 9:23:34 PM UTC+0 (timestamp)
. But I need only the date part, such as '11-11-2021'. Is there any way to save only the date part with Firebase server timestamp?
Code:
val docData = hashMapOf(
"stringExample" to "Hello world!",
"dateExample" to Timestamp(Date()).toDate(), //want only date part. Also is there alternative of using Date()?
"nullExample" to null
)
db.collection("data").document("one")
.set(docData)
.addOnSuccessListener { Log.d(TAG, "DocumentSnapshot successfully written!") }
.addOnFailureListener { e -> Log.w(TAG, "Error writing document", e) }
Want to do this because it's better not to strip data on some usage such as for small iot device.