Linked Questions

Popular Questions

In MySQL I have an attribute P10 which is a decimal(6,2). If I echo it in Yii2, I'm getting 20,45 - why the comma, why not point? It doesn't matter how I'm setting decimalSeparator in config. If I multiply the 20,45 with 2.1 I'm getting 42 instead of 42.945 so it seems 20,45 is truncated to 20 when using in calculations and I have no idea why. I have already spent a lot of time with searching and it drives me slowly crazy.

Interesting also, I'm echoing two attributes in Yii2 gridview and both are decimal(6,2) in MySQL, but still the one is echoed with a point as decimal separator and the other as a comma...?

Do I have to explicitly tell Yii2 that a decimal is a decimal, and format it extra as a decimal ??

Can you please point me to the right direction?

the code:

public function getMea5() {
    return $this->P10 * 2.1;
}

Related Questions