Invalidpipeargument error when using Datepipe

Asked

Viewed 31 times

0

I’m making an application in Angular and I’m trying to show a date, coming from the database, in a table.

I have a database, as I mentioned above, which has a field for storing dates, like Timestamp. I also have a Date type variable in my Angular System to store that date.

Now, when I do Interpolation, {{}}, of this variable in HTML, the browser displays the date as Invalid Date and when I use the same variable, but with Datepipe (| date), this error message is displayed in the browser console:

inserir a descrição da imagem aqui

  • 1

    see in the code you are passing the database value to the variable or class, at this point it must be converting incorrectly, and arrives as "Invalid Date" when you will use Angular to display in HTML, and if you are like a string with that text, will give error while trying to convert to date using | date

  • Most importantly there you did not put in the question that is an example of date coming from the bank! Creates a variable and inserts a test-only date and uses the pipe in html if no error is detected, probably the problem is in the dates coming from the database!

  • As @Leandrade suggested, I created a variable and entered a date, I entered it into HTML and it did not fail. The problem must come from the database... : 2020-06-09 16:30:42.172000

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.