nikosmart / yii2-timezone
基于 Google Timezone API 的时区客户端,具有扩展其他提供商的功能。
dev-master
2023-03-26 07:40 UTC
Requires
- php: ^7
- guzzlehttp/guzzle: 6.*
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-09-21 02:13:37 UTC
README
基于 Google Timezone API 的时区客户端,具有扩展其他提供商的功能。
安装
安装此扩展的首选方式是通过 Composer。
运行
php composer.phar require --prefer-dist nikosmart/yii2-timezone "*"
或添加
"nikosmart/yii2-timezone": "*"
到您的 composer.json
文件的 require 部分。
使用方法
扩展安装后,只需在您的代码中使用即可
<?= $time = (new \nikosmart\timezone\TimezoneDetect()) ->request([ 'lat'=>46.965900, 'lng'=>31.997400 ]); ?>
根据 Google 的说法,这个请求应该计算本地时间。
给定位置的本地时间是从结果中的 timestamp 参数、dstOffset 和 rawOffset 字段的总和。更多详情请参阅 https://developers.google.com/maps/documentation/timezone/start