mrcage/chf-exchange-rates

根据瑞士联邦海关管理局网站的数据,检索外币的瑞士法郎汇率。

3.0.0 2023-08-09 18:32 UTC

This package is auto-updated.

Last update: 2024-09-09 20:49:51 UTC


README

根据瑞士联邦海关管理局网站的数据,检索外币的瑞士法郎汇率。

https://www.estv.admin.ch/estv/en/home/value-added-tax/accounting-vat/vat-foreign-exchange-rates.html

该库使用内部缓存请求的数据(缓存时间为一周)。

用法

包含类

use MrCage\EzvExchangeRates\EzvExchangeRates;

获取当前日期的汇率

$rate = EzvExchangeRates::getExchangeRate('EUR');

获取过去某天的汇率

日期必须指定为 Carbon 日期对象。

$rate = EzvExchangeRates::getExchangeRate('USD', Carbon::yesterday());

获取所有可用的货币

$currencies = EzvExchangeRates::listCurrencies();

这将返回一个包含货币代码的数组,键为(大写)货币代码,值为汇率使用的基准值。