Reputation: 128
I am using this function
Yii::$app->formatter->asCurrency(12321.00, 'EUR');
The result is 12 321,00 €. But I wanted it to show 12 321 € if the decimals are 00...
Upvotes: 3
Views: 1266
Reputation: 818
To anybody looking for this recently, it's possible to set this globally for all numbers via https://www.yiiframework.com/doc/api/2.0/yii-i18n-formatter#$numberFormatterOptions-detail
'formatter' => [
'numberFormatterOptions' => [
NumberFormatter::MIN_FRACTION_DIGITS => 0,
NumberFormatter::MAX_FRACTION_DIGITS => 2,
]
],
Upvotes: 0
Reputation: 14459
Another way would be:
\Yii::$app->formatter->asCurrency(12321.00, 'EUR',[\NumberFormatter::MAX_SIGNIFICANT_DIGITS=>100])
Output:
€12,321
-
\Yii::$app->formatter->asCurrency(9912321.00, 'EUR',[\NumberFormatter::MAX_SIGNIFICANT_DIGITS=>100])
Output:
€9,912,321
Upvotes: 5