ChrisTERiS Posted February 5, 2021 Share Posted February 5, 2021 (edited) 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 February 5, 2021 by WHMUp Typo in Title 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 6, 2021 Share Posted February 6, 2021 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. 0 Quote Link to comment Share on other sites More sharing options...
ChrisTERiS Posted February 6, 2021 Author Share Posted February 6, 2021 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   0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 6, 2021 Share Posted February 6, 2021 12 minutes ago, WHMUp said: I want to learn the right way $prefix_amount = $full_amount->toPrefixed(); 🙂  1 Quote Link to comment Share on other sites More sharing options...
ChrisTERiS Posted February 6, 2021 Author Share Posted February 6, 2021 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 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.