79254326

Date: 2024-12-05 10:48:54
Score: 0.5
Natty:
Report link

The type of the date must be a string (for the calendar component)

I use the type Date. That must be converted to a string in the given format.

so I used mm/yy (primeNG formatting) which translates to "12/2024"

import { DatePipe } from '@angular/common';

constructor(private datePipe: DatePipe) { }

ngOnInit(): void {
  this.date = this.datePipe.transform(new Date(), 'MM/yyyy');
}

The solution can be that simple :)

Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Babulaas