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 On 2/5/2021 at 7:26 PM, 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. Expand 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 On 2/6/2021 at 11:09 AM, 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. Expand 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 On 2/6/2021 at 3:39 PM, WHMUp said: I want to learn the right way Expand $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 On 2/6/2021 at 3:51 PM, brian! said: $prefix_amount = $full_amount->toPrefixed(); 🙂 Expand 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.