amaccis / tai64-datetime
1.0.1
2019-09-30 21:09 UTC
Requires
- php: ^7.1
Requires (Dev)
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2023-03-19 21:32:16 UTC
README
这是一个扩展 DateTime 类的 PHP 库,以便可以处理 Tai64。
安装
该软件包可在 Packagist 上找到,您可以使用 Composer 安装它。
composer require amaccis/tai64-datetime
基本用法
如果您需要了解 TAI、TAI64、TAI64N 和 TAI64NA 的基本知识,请阅读此内容。相反,如果您想了解更多关于闰秒的信息,请阅读此内容。目前不管理 TAI64N 和 TAI64NA。
将 TAI64 转换为 UTC
use Amaccis/Tai64DateTime/DateTime $dateTime = new DateTime("400000002a2b2c2d"); $utc = $dateTime->format('Y-m-d H:i:s'); var_dump($utc); // 1992-06-02 08:06:43
将 UTC 转换为 TAI64
use Amaccis/Tai64DateTime/DateTime $dateTime = new DateTime("1992-06-02 08:06:43"); $hexString = $dateTime->format("TAI64"); var_dump($hexString); // 400000002a2b2c2d'