Nitin Pund
Nitin Pund

Reputation: 1092

Yii2 Currency Formatter set 4 fractions after decimal

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,
  ]

Upvotes: 0

Views: 690

Answers (1)

Bizley
Bizley

Reputation: 18021

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.

Upvotes: 1

Related Questions