formatting - JavaScript - Intl. Numberformatter show € before value - Stack Overflow

When using a numberformatter in JavaScript, is it possible to format the value with the euro sign befor

When using a numberformatter in JavaScript, is it possible to format the value with the euro sign before the value?

this.formatter = new Intl.NumberFormat('nl-be', {
  style: 'currency',
  currency: 'EUR',
  minimumFractionDigits: 2
});

this.formatter.format(2000);

The code sample from above returns 2000.00€ instead of €2000.00

When using a numberformatter in JavaScript, is it possible to format the value with the euro sign before the value?

this.formatter = new Intl.NumberFormat('nl-be', {
  style: 'currency',
  currency: 'EUR',
  minimumFractionDigits: 2
});

this.formatter.format(2000);

The code sample from above returns 2000.00€ instead of €2000.00

Share Improve this question asked Feb 6, 2018 at 8:59 Dennis SchiepersDennis Schiepers 1371 silver badge12 bronze badges 2
  • This does not seem to be technically wrong, according to stackoverflow./a/7570778/1427878 And I don’t see Intl.NumberFormat offering any additional options regarding the currency symbol position ... so I guess if you really need this, you will have to manipulate the resulting value yourself somehow. – C3roe Commented Feb 6, 2018 at 9:05
  • In Standard Dutch , the currency symbol is always placed before the amount. – Dennis Schiepers Commented Feb 6, 2018 at 9:28
Add a ment  | 

1 Answer 1

Reset to default 8

Two ways:

  1. Use another locale. Here's a list of the supported ones. From there, I took the belgium one (sfb), which renders the sign in front of the number.

    this.formatter = new Intl.NumberFormat('sfb', {
      style: 'currency',
      currency: 'EUR',
      minimumFractionDigits: 2
    });
    
    this.formatter.format(2000);
    
  2. Parse it yourself to move the sign in front of the string:

    var str = this.formatter.format(2000);
    var result = str.substr(str.length-1)+ str.substr(0,str.length-1)
    

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744266631a4565895.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信