Documentation

GetConvertFactor

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

This method returns the factor for converting amounts from curFrom currency to curTo currency at the exchange rate, set on the date valDate. Static method. Use GetConvertFactorEx method instead of this method starting from 16.0.0 version.

Parameters

ParameterDescription
curFrom Source currency.
curTo Destination currency.
valDateThe date of the exchange rate at which the conversion is to be performed. If the date is empty, the conversion is performed at the current rate. The date shall be specified in the YYYY-MM-DD format.

Return Values

Conversion factor is returned.

Example


<?
$arVals = array(11.95, 18.27, 5.01);
$rate_cost = CCurrencyRates::GetConvertFactor("GBP", "USD");
for ($i = 0; $i < count($arVals); $i++)
{
    echo $arVals[$i]." GBP = ".Round($rate_cost*$arVals[$i], 2)." USD";
}
?>
© «Bitrix24», 2001-2024