How to change the currency format in cakephp 3

I want to change the format of $this->Number->currency($product->price,‘HKD’);
How and where do I need to set the format?

You just need to change your locale.

I want to display multiple currencies in the same page. Not setting locale but display the correct currency by using the helper. $this->Number->currency($product->price,‘USD’); $this->Number->currency($product->price,‘HKD’);

Then the way HKD is displayed in the page, is not the way I want it to appear…

What do you mean “is not the way I want it to appear”?
Could you give a sample of what it shows vs. what you want?

When it is HKD, it shows as $xxxxx, but since I have usd as well on the same page, I want to show it as HK$xxxxx. So the question is where can one adjust the way it is displayed?

I see, then you could write it as so:

$this->Number->currency($product->price,'HKD', ['before' => 'HK']);

That should display it as HK$1234

Can you set it somewhere in a general config file?

actually I found that it is set correctly i just made a mistake with the database field that is called currency_code instead of currency…

:upside_down_face:

1 Like