Last active
September 28, 2020 16:35
-
-
Save RuslanAsadov/004ed1f615e3683ad5c23fd41d3c0d2f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$fmt = new NumberFormatter( 'ru_RU', NumberFormatter::CURRENCY ); | |
$fmt->setAttribute(NumberFormatter::FRACTION_DIGITS, 0); | |
$fmt->setSymbol(NumberFormatter::CURRENCY_SYMBOL, '₽'); | |
$price = $fmt->formatCurrency($price, "RUR")."\n"; | |
// Function | |
function beauty_price_value($value = 0, $currency = 'rub') { | |
$locale = 'ru_RU'; | |
$currency_slug = 'RUR'; | |
if($currency == 'usd') { | |
$locale = 'en_US'; | |
$currency_slug = 'USD'; | |
} | |
if($currency == 'eur') { | |
$locale = 'en_US'; | |
$currency_slug = 'EUR'; | |
} | |
$fmt = new NumberFormatter($locale, NumberFormatter::CURRENCY); | |
if($currency == 'rub') { | |
$fmt->setSymbol(NumberFormatter::CURRENCY_SYMBOL, '₽'); | |
} | |
$fmt->setTextAttribute(NumberFormatter::CURRENCY_CODE, $currency_slug); | |
$fmt->setAttribute(NumberFormatter::FRACTION_DIGITS, 0); | |
return $fmt->formatCurrency($value, $currency_slug); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const formatter = new Intl.NumberFormat('ru-RU', { | |
style: 'currency', | |
currency: 'RUB', | |
minimumFractionDigits: 0, | |
}) | |
const price = formatter.format(val) | |
// Format to Rubles |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment