Is there a way to make the datepipe dynamic so that if it's an American browser the datepipe returns the American format (yyyy/MM/dd) and when it's a European browser it returns the European format (dd/MM/yyyy)?
Thanks
Is there a way to make the datepipe dynamic so that if it's an American browser the datepipe returns the American format (yyyy/MM/dd) and when it's a European browser it returns the European format (dd/MM/yyyy)?
Thanks
I think you should use native JS API
Date.prototype.toLocaleDateString()
to achieve this goal. See this link.You can implement your own Angular pipe to use this API.
You can check the location and put it in if statement Yes you can use pipe like this :
To find location
}
This can be hard, especially when using aot. It would normally require you to make different builds. I extended the datapipe and use the browsers locale.
Datepipe:
Window: