To change the format of a date to dd/MM/yyyy
, I have created a custom pipe as shown below:
import { Pipe, PipeTransform } from '@angular/core';
import { DatePipe } from '@angular/common';
@Pipe({
name: 'dateFormat',
})
export class DateFormat implements PipeTransform {
transform(value: string) {
var datePipe = new DatePipe("fr-FR");
return datePipe.transform(value, 'dd/MM/yyyy');
}
}
When I use this pipe in my code like this:
this.editOrganizationForm.patchValue({
startDate: this.dateFormat.transform(organization.effectiveDate.startDate);
})
I encounter the following issue:
The specified value "02/05/1999" does not match the expected format, which is "yyyy-MM-dd".