0

I want to set 4 digit fractions after decimal,

for example : Yii::$app->formatter->asCurrency($model->amount) 

current output is : $ 65.58
expected output is : $ 65.5765

I have tried this link, but i m getting error as "Class 'NumberFormatter' not found".

How can I use following properties in my main config file, these properties are mentioned in Formatter class

  [
      NumberFormatter::MIN_FRACTION_DIGITS => 0,
      NumberFormatter::MAX_FRACTION_DIGITS => 2,
  ]
Community
  • 1
  • 1
Nitin Pund
  • 1,082
  • 2
  • 9
  • 23

1 Answers1

1

This property takes only effect if the PHP intl extension is installed. Install intl and class NumberFormatter will be available. The rest is just like in your configuration.

Bizley
  • 17,392
  • 5
  • 49
  • 59
  • @ Bizley : Thanks, it works fine after installing the [PHP intl extension.](http://php.net/manual/en/book.intl.php). I have one more question, is there any way to get a currency symbol using currency code? – Nitin Pund Sep 12 '16 at 09:18
  • 1
    Add currency code here: `Yii::$app->formatter->asCurrency($amount, $currencyCode)` $currencyCode must be 3-letter ISO 4217 code and will be displayed according to your `locale` settings. – Bizley Sep 12 '16 at 09:30
  • Thanks for your help .. !! – Nitin Pund Sep 12 '16 at 09:31