Recently Angular DatePipe is showing an InvalidPipeArgument error but the String date seams to be correct. Can any one see some error? this is my code using Typescript and Angular 6
let datePipe: DatePipe = new DatePipe("es-ES");
let dia_sele: string = "";
try {
let fecha_formateada = this.datePipe.transform('23-01-2019', 'dd-MM-yyyy','es-ES');
dia_sele = fecha_formateada;
} catch (e) {
dia_sele = "";
console.log( "->err:" + e);
}
And this is the error showing in console from Chrome Windows:
core.js:14597 ERROR Error: Uncaught (in promise): Error: InvalidPipeArgument: 'Unable to convert "23-01-2019" into a date' for pipe 'DatePipe'
Error: InvalidPipeArgument: 'Unable to convert "23-01-2019" into a date' for pipe 'DatePipe'
at invalidPipeArgumentError (common.js:4013)
at DatePipe.transform