I'm trying to populate a table from a firestore database which has field value timestamp data:
with the following code for web:
firebase.initializeApp(firebaseConfig);
const attendanceCollection = firebase.firestore().collection("attendance");
var lastIndex = 0;
function getData() {
var htmls = [];
attendanceCollection.get().then(querySnapshot => {
querySnapshot.forEach(doc => {
console.log(`${doc.id}`);
console.log(`${(doc.data().GENERALASSEMBLY)}`)
htmls.unshift('<tr>\
<td>'+ `${doc.id}` +'</td>\
<td class="message" style=" text-overflow: ellipsis">'+ `${(doc.data().GENERALASSEMBLY)}` +'</td>\
<td style="overflow: hidden; text-overflow: ellipsis">'+ `${doc.id}` +'</td>\
</tr>');
});
$('#tbody').html(htmls);
$("#submitUser").removeClass('desabled');
});
};
I've found some references but never actually helped me solve what I'm trying to make:
How to get a JavaScript Date object from the new `firebase.firestore.FieldValue.serverTimestamp()`
How do I convert a Firestore date/Timestamp to a JS Date()?
how do I implement the toDate() in my code above? can you give me samples of using toDate() on converting firestore timestamps to date/string?