Documentation

ConvertCurrency

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

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

Parameters

ParameterDescription
valSum Amount in the curFrom currency to be converted to the curTo currency.
curFrom Source currency.
curTo Destination currency.
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";
?>
© «Bitrix24», 2001-2024