Reputation: 1059
I have to use HTML5 input type='date' for my angular 6 application. I want to Show it as dd/MM/yyyy format. But when I change Local pc time format as yyyy-MM-dd chrome automatically change the time format to local pc time format. But I want to set it as dd/MM/yyyy for all users. (Because their pc time formats can be different) How can I Solve this problem. Is their any method to format it.
If I put format attribute as follows it will not work.
<input type="date" format="dd/MM/yyyy"/>
Upvotes: 1
Views: 11002
Reputation: 8642
The short answer is that its not currently possible to do format the date (there is no format
attribute available).
However, you probably want a solution, so here are some options that you might want to try
1) Use an <input type='text'>
for display, and have a hidden <input type='date'>
for when the user tries to open the date-picker (it might not be easy to open the native date picker programmatically), and have JavaScript put the date from the date-picker into the input type text
2) Just use a library with a customizable date picker like the Angular Material DatePicker with the setLocale method
Upvotes: 2