admin管理员组文章数量:1415698
Let's say we have these 2 values
1.230
That means in Italy one thousand and 230, if an American had to write that, would write
1,230
Currently using:
myValue.toLocaleString('it');
For US we should be using myValue.toLocaleString('en-US');
How would we detect the correct number format we should be displaying?
Let's say we have these 2 values
1.230
That means in Italy one thousand and 230, if an American had to write that, would write
1,230
Currently using:
myValue.toLocaleString('it');
For US we should be using myValue.toLocaleString('en-US');
How would we detect the correct number format we should be displaying?
Share Improve this question asked May 9, 2020 at 9:12 rob.mrob.m 10.6k21 gold badges88 silver badges175 bronze badges 1- Related: Javascript toFixed localized?. – Sebastian Simon Commented Jan 19, 2023 at 0:51
2 Answers
Reset to default 8Do you want something like that?
myValue.toLocaleString(navigator.language)
You can use Intl.NumberFormat as
var number = 3500;
console.log(new Intl.NumberFormat().format(number));
本文标签: javascriptHow to get numbers format based on user locationStack Overflow
版权声明:本文标题:javascript - How to get numbers format based on user location? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745238029a2649152.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论