I have a problem with angular2 date date when using Danish locale.
When I format the date, for example:
{{myDate | date:'dd-MM-yyyy'}}
it displays the day of the date with a suffix like this:
17.-03-2017
allthough, I would expect it to be like this:
03/17/2017
The locale is set in app.module as follows:
providers: [ {provide: LOCALE_ID, useValue: 'da-DK'} ]
I made this plnkr to make it more understandable http://plnkr.co/edit/A5ddrKP5cmsSZ9bTqzPh
UPDATE
This is likely due to the way dates are dated in Danish. Se below:
var locale = 'da-DK';
var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
var date = new Date(2017,2,17); var result = new Intl.DateTimeFormat(locale, options).format(date);
alert(result);
turns into → fredag den 17. marts 2017
Pay attention to the point
source
share