THE SITUATION:
From the API i get the dates in the european format: 01-06-2018
That is: day - month - year (1 june 2018).
I need to display in a more beautiful way - the 'd MMM y' format is exactly what I need.
But if i use the pipeline in the view in this way:
{{ projectInfo.project_start_date | date: 'd MMM y' }}
The result is: 6 Jan 2018
(while in my case should be 1 Jun 2018
)
Because it thinks that the first two cyphers of my date 01-06-2018
are the month - while they are days..
THE QUESTION:
How can convert European formatted dates in Angular 2?
Should I convert them in the component from European format to American format?
If yes - do you know how that can be done in Angular 2?
Thanks!
EDIT:
This how I have tried to convert the string i received from the API into an actual date:
In the component:
dateTest: Date;
this.dateTest = new Date(this.projectInfo['project_start_date']);
In the view:
<span> {{ dateTest | date: 'd MMM y' }} </span>
The result:
Still the same: 6 Jan 2018
PLUNKER: