Bitrix Site Manager

CCurrencyRates::ConvertCurrency

float
CCurrencyRates::ConvertCurrency(
 float valSum,
 string curFrom,
 string curTo,
 string valDate = ""
);

The method ConvertCurrency is used to convert the amount valSum from currency curFrom to currency curTo at the exchange rate set on the date valDate

Parameters

ParameterDescription
valSum Amount in the curFrom currency which is to be converted to the curTo currency.
curFrom The currency to be converted.
curTo The currency to which the conversion is to be performed.
valDate The date of the exchange rate is to be used for conversion. If the date is empty, the conversion is performed at the current rate.

Return Values

The amount in the destination currency.

Example


<?
// suggest the USD and EUR currencies exist in the database
$val = 11.95; // amount in USD
$newval = CCurrencyRates::ConvertCurrency($val, "USD", "EUR");
echo $val." USD = ".$newval." EUR";
?>