litipk/php-jiffy

此包已被弃用,不再维护。未建议替代包。

一个用于轻松处理精确时间戳的库。

1.4.0 2016-06-06 21:45 UTC

This package is auto-updated.

Last update: 2024-01-07 19:55:16 UTC


README

Author Build Status Coverage Status Quality Score Software License Packagist Version Total Downloads

安装

composer require litipk/php-jiffy

使用

PHP Jiffy 库提供了 UniversalTimestamp 类,允许您以毫秒和微秒的精度记录时间戳,并在需要时将其转换为其他“时间戳类型”。

支持的 PHP 版本是 5.55.67.0HHVM

<?php

use Litipk\Jiffy\UniversalTimestamp;

$now = UniversalTimestamp::now();
$fromDateTime = UniversalTimestamp::fromDateTimeInterface(new \DateTime());
$fromMongoDate = UniversalTimestamp::fromMongoDate(new \MongoDate());

注意: MongoDB 相关的方法仅在加载了 mongomongodb 扩展时才可用。

与 Doctrine 的集成

如果您想在 Doctrine 模型中使用 Jiffy 的 UniversalTimestamp 对象,可以使用我们的适配层