alxdorosenco / ecb-rates
此包使用欧洲中央银行的汇率参考率
v1.0.1
2024-04-21 09:27 UTC
Requires
- php: ^7.0|^8.0
Requires (Dev)
- phpunit/phpunit: ^6.0
This package is auto-updated.
Last update: 2024-09-21 10:18:29 UTC
README
欧洲中央银行货币汇率转换器
最新汇率属性的URL: https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml
存档汇率属性的URL: https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist.xml
安装
使用Composer要求此包
$ composer require alxdorosenco/ecb-rates
使用方法
最新汇率属性
<?php require __DIR__ . '/vendor/autoload.php'; use AlxDorosenco\EcbRates\CurrencyRates; // Latest rate attributes initialization $daily = CurrencyRates::daily(); // Exchange 20 EUR to USD $daily->rate(20, 'EUR', 'USD'); // Exchange 20 EUR to USD - special option $daily->euroTo(20, 'USD'); // Exchange 20 USD to JPY $daily->rate(20, 'USD', 'JPY');
历史汇率属性
<?php require __DIR__ . '/vendor/autoload.php'; use AlxDorosenco\EcbRates\CurrencyRates; $history = CurrencyRates::history(); // History rate attributes initialization // Get array of the rate attributes to the 2021-02-10 date $history->findByDate('2021-02-10'); // Exchange 20 EUR to USD from the rate attributes to the 2021-02-10 date $history->findByDate('2021-02-10')->rate(20, 'EUR', 'USD'); // Exchange 20 EUR to USD from the rate attributes to the 2021-02-10 date - special option $history->findByDate('2021-02-10')->euroTo(20, 'EUR', 'USD'); // Get array of the latest rate attributes $history->findByDate(); // Exchange 20 EUR to USD from the latest rate attributes $history->rate(20, 'EUR', 'USD'); // Exchange 20 EUR to USD from the latest rate attributes - special option $history->rate(20, 'EUR', 'USD')->euroTo(20, 'EUR', 'USD');
所有可能的货币代码
- USD
- JPY
- BGN
- CZK
- DKK
- GBP
- HUF
- PLN
- RON
- SEK
- CHF
- ISK
- NOK
- HRK
- RUB
- TRY
- AUD
- BRL
- CAD
- CNY
- HKD
- IDR
- ILS
- INR
- KRW
- MXN
- MYR
- NZD
- PHP
- SGD
- THB
- ZAR