I am trying to format a timestamp into a more readable date format. Currently, the timestamp I receive looks like this:
2018-10-10T05:00:00.000Z
What I want to achieve is: 2018-10-10 05:00 PM
This is how I am querying the document containing the timestamp object:
ListAppointments(){
var query = firebase.firestore().collection("doctorAgenda")
var auxint = 0;
this.dataAux
let auxString = '[';
query.where('Deleted', '==', false).get().then(res => {
res.forEach(item => {
auxint++;
auxString += '{"id":"' + item.id + '","doctorAgenda":' + JSON.stringify(item.data()) + '}';
console.log(item);
if (res.size != auxint)
auxString += ', ';
})
auxString += ']';
this.dataJSON = JSON.parse(auxString);
console.log(auxString);
console.log(this.dataJSON);
}).catch(err => {
console.log('An error occurred ' + err);
});
}
This is how I am displaying it in HTML
<ion-content padding>
<div padding-top class="card" *ngFor="let data of dataJSON">
<div class="card__appointment review">
<div class="card__appointment--header">
<h3>Cardiology appointment - {{data?.doctorAgenda?.Document?.Specialty}}</h3>
<span>Cardiology</span>
</div>
<div class="card__appointment--content">
<span>Appointment held at: {{data.doctorAgenda.Document.EndTime}}</span>
</div>
<ion-row align-items-center class="card__appointment--footer">
<ion-col>
<span>Confirmation code:</span>
<strong>99887</strong>
</ion-col>
<ion-col col-5 center text-center>
<button class="btn btn-outline-secondary">
Review
</button>
</ion-col>
</ion-row>
</div>
</div>
</ion-content>