Moment js and date pipe


I’m trying to use the date pipe from angular (5) which i believe uses moment js. We already use moment in a component which works fine, when a user logs in we bind its language to moment.locale. However the date pipe does not seem to use this setting. Also i tried using a datePipeProxy which initialises a new date pipe with the correct language but it says it does not support ‘nl’ as a locale.

Does anybody have any ideas ?

With best regards,

No, it doesn’t.

Angular by default only has the en_US locale. You need to add other ones yourself. See the Angular i18n docs.

Thanks, I dont know why i thought the date pipe used moment js.

Since i need to change translations on the go i opted for a custom pipe which does use moment.js. Their are some work around available for changing the date pipe translation on the go but i really like moment js so i opted for that instead.

Thanks for the help.

I used to too, but now I consider date-fns to be vastly superior. It is much more lightweight and works on either ISO8601 strings or JavaScript Dates, instead of needing the unwieldy moment object, which makes dealing with dates coming across the network much simpler. Fellow forum poster @AaronSterling has also made a set of date pipes that work with it.