Is there a functionality in JavaScript to convert values into specific locale formats?

前端 未结 9 1834
花落未央
花落未央 2020-12-03 06:32

Is there a built in function of JavaScript to convert a string into a particular locale (Euro in my case)?

E.g. 50.00 should get converted to 50,0

9条回答
  •  时光说笑
    2020-12-03 07:10

    I have prepared small library to deal with currency formatting - money

    money(1000.5, 'EUR');   // -> 1 000.50 €
    money(1000.5, 'USD');   // -> $1,000.50
    money(1000.5, 'PLN');   // -> 1 000,50 zł
    

    Supported currency (ISO codes): PLN, EUR, USD, GBP, JPY, CZK, SEK

提交回复
热议问题