I have been working with Angular 5 to show a timeline. The start and end dates are stored in DB sent from the back-end via REST.
I am getting the dates in the following format.
Start: 02-12-2019 11:26
End: 13-12-2019 13:14
As I need to convert this date to a given format, 'dd-MM-yy' I tried using datepipe and I was getting Invalid pipe argument error for the second date. -> "InvalidPipeArgument: '13-12-2019 13:14' for pipe 'DatePipe'"
Then I tried to print the dates using
Date startDate = new Date(startDateIn);
Date endDate = new Date (endDateIn);
Output:
Start Date: Tue Feb 12 2019 11:26:00 GMT+0530 (India Standard Time)
End Date: Invalid Date
Is there any way to make Angular know that the input date is in 'dd-mm-yyyy HH:mm' format?
As the all mentionned above you need to format the date due to Javascript formatting your date on the wrong way, now he made a mistake.
You should us that method, but add the + in front of the dateParts element to convert them from string to number :)