Reputation: 2013
i want to convert a date to specific format (dd/MM/yyyy
) , so i created the below pipe
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 it like this
this.editOrganizationForm.patchValue({
startDate: this.dateFormat.transform(organization.effectiveDate.startDate);
})
is show the below working
The specified value "02/05/1999" does not conform to the required format, "yyyy-MM-dd".
Upvotes: 2
Views: 4287
Reputation: 420
The specified value "02/05/1999" does not conform to the required format, "yyyy-MM-dd".
you return date in format 'dd/MM/yyyy'
return datePipe.transform(value, 'dd/MM/yyyy');
why not
return datePipe.transform(value, 'yyyy-MM-dd');
Upvotes: 2