I need to convert amount from one currency to another currency in magento 2 not from store base currency
$priceCurrencyObject = $objectManager->get('Magento\Framework\Pricing\PriceCurrencyInterface'); //instance of PriceCurrencyInterface
$store = $this->_storeManager->getStore()->getStoreId(); //get current store id if store id not get passed
$rate = $priceCurrencyObject->convert($USDamount, $store, 'INR');
I tried above code it will convert base currency to another currency.
My criteria is I need to mention from currency and to currency.
Is it possible in magento2
Best Answer
You can use this code (or whole class) to convert from the one currency to another:
Additional, if you do not specify the currency from which you want to conver - current currency will be used. If you do not specify the currency in which you want to convert - base currency will be used.