Skip to content

Instantly share code, notes, and snippets.

@khoand0000
Created October 28, 2015 10:00
Show Gist options
  • Save khoand0000/0ba7c416bb9ec1b6461d to your computer and use it in GitHub Desktop.
Save khoand0000/0ba7c416bb9ec1b6461d to your computer and use it in GitHub Desktop.
money_format is not working with Vietnamese
$number = 1234.56;
// let's print the international format for the en_US locale
setlocale(LC_MONETARY, 'en_US');
echo money_format('%i', $number) . "\n";
// USD 1,234.56
// but if using vi_VN or vi_VN.UTF-8, not working
setlocale(LC_MONETARY, 'vi_VN');
echo money_format('%i', $number) . "\n";
// 1234.56
@anhducbkhn
Copy link

@anhducbkhn
Copy link

$fmt = numfmt_create( 'vi_VN', \NumberFormatter::CURRENCY );
numfmt_format_currency($fmt, $product->price, 'VND')

result:
300.000 ₫

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment