I have an app with a calendar, I want to add events to this calendar by fetching data from firebase on events and passing the dates through.
I have made a sample collection called 'competition' with a date in timestamp format.
When i console.log(), I can see the timestamp which is called datecomp is being passed through in Epoch seconds as below datecomp: t {seconds: 1585396800, nanoseconds: 0}
How can I convert this in Angular to get in the format of a date which can be used in the calendar?
The basic code I have so far is here for reference
Any help would be appreciated
TypeScript:
import { Component } from ‘@angular/core’;
import {tap} from ‘rxjs/operators’;
import {AngularFirestoreModule, AngularFirestore} from ‘@angular/fire/firestore’;
import {Injectable} from ‘@angular/core’;
@Component({
selector: ‘app-home’,
templateUrl: ‘home.page.html’,
styleUrls: [‘home.page.scss’],
})
export class HomePage {
date: string;
type: ‘string’;
constructor(private afs:AngularFirestore) {
this.afs.collection(‘competition’).valueChanges().subscribe(data=>{console.log(data);
})
}
HTML
Calendar Page
<ion-calendar [(ngModel)]="date"
(onChange)="onChange($event)"
[type]="type"
[format]="'YYYY-MM-DD'">
</ion-calendar>