I wanted to get firebase current timestamp, not able to find a way to get that. I want to save child as shown in the image. And for that I\'ve to get timestamp and get the d
On Android I did it this way
index.js / serverside
const functions = require('firebase-functions');
exports.stamp = functions.https.onCall(() => {
var d = new Date();
console.log('TimeStamp_now : '+d.getTime());
return { timeStamp: d.getTime() };
});
someclass.kt / clientside
lateinit var functions: FirebaseFunctions
var ret :Long = 0
FirebaseApp.initializeApp(this)
functions = FirebaseFunctions.getInstance()
val returnFC = functions.getHttpsCallable("stamp").call()
returnFC.continueWith { task ->
val resultFC = task.result?.data as Map
resultFC["timeStamp"] as Long
ret = "${resultFC["timeStamp"]}".toLong()
val cal = Calendar.getInstance()
cal.timeInMillis = "$ret".toLong()
var date = DateFormat.format("dd-MM-yyyy", cal).toString()
Log.d("current date:", date)
Log.d("timeStamp_from_function :", "$ret")
resultFC
}
returnFC.addOnSuccessListener {
Log.d("OnSuccessListener :", "success")
}
returnFC.addOnFailureListener {
Log.d("OnFailureListener:", "failure")
}
I got the return and arrived at: TimestampConvert look great