Jump to content
WHMUp

Any similar to fromMySQLDate function for Price format

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

Share this post


Link to post
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.

Share this post


Link to post
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

 

 

Share this post


Link to post
Share on other sites
12 minutes ago, WHMUp said:

I want to learn the right way

$prefix_amount = $full_amount->toPrefixed();

🙂

 

Share this post


Link to post
Share on other sites
4 minutes ago, brian! said:

$prefix_amount = $full_amount->toPrefixed();

🙂

 

So easy 🙂 .... I've wrote even 5 lines of code, trying to make it working. And it was just that "->" 🙂

Thank you

Share this post


Link to post
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