Reputation: 815
How to display the value of this base on user's locale/culture?
Right now it displaying US format (mm/dd/yy) and I need UK format (dd/mm/yy).
I would also like to display base on thes user's locale format or detect where's the user's locale.
Something like the javascript toLocaleString().
<input type="datetime-local" value="">
Upvotes: 1
Views: 2885
Reputation: 14216
That is not supported by browser yet. See following post.
http://weblog.west-wind.com/posts/2012/Nov/08/HTML5-Input-typedate-Formatting-Issues.
So you need to manage it via server side code for example If you want to do it with ASP.NET here is the post which will help you.
http://msdn.microsoft.com/en-us/library/bb882561(v=vs.110).aspx
For JavaScript, you need to use tolocalstring as you have mentioned in your question. http://www.w3schools.com/jsref/jsref_tolocalestring.asp
Upvotes: 1
Reputation: 104770
navigator.isBritish=(function(){
return new Date('12/6/2009').getMonth()===5;
})();
Handy for setting up the order of inputs and date displays, anyway.
Upvotes: 1