Jump to content

Any similar to fromMySQLDate function for Price format


ChrisTERiS

Recommended Posts

Hello,

@brian! gave me a great function to use to format dates.

fromMySQLDate($decodedata[$key]["postdate"],true,true);

I wonder if there is any similar function to format a number with currency settings. Perfectly for user settings but even with global settings is fine for me.

Thank you

Chris

Edited by WHMUp
Typo in Title
Link to comment
Share on other sites

15 hours ago, WHMUp said:

I wonder if there is any similar function to format a number with currency settings. Perfectly for user settings but even with global settings is fine for me.

https://developers.whmcs.com/advanced/currency-formatting/

you'll end up with a price formatter variable that you can manipulate as detailed in the class docs.

Link to comment
Share on other sites

4 hours ago, brian! said:

https://developers.whmcs.com/advanced/currency-formatting/

you'll end up with a price formatter variable that you can manipulate as detailed in the class docs.

Have messed my mind 😞 This code:

$currencyData = getCurrency($userId);
$amount = 82;
$full_amount = formatCurrency($amount, $currencyData['id']);

return $82.00 USD which is correct. Now I want to use toPrefixed() to show the price only with prefix. Even if I was expected that it does not works, I gave a try: toPrefixed($full_amount) but I got error: undefined function. Normal as it's a class. Sure I can remove suffix using substr($full_amount, 0, -4) but I want to learn the right way 🙂

Thank you

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated