navarr/specific-time

PSR-20 的静态时间和日期实现

资助包维护!
navarr

v1.0.0 2022-11-26 18:49 UTC

This package is auto-updated.

Last update: 2024-08-26 22:17:35 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License
Tests Code Coverage Mutation score

这是一个 PSR-20 的实现,无论对象上调用多少次 ->now(),都提供恒定的时间。

安装

composer require navarr/specific-time:^1

用法

use DateTimeImmutable;
use Navarr\SpecificTime\SpecificTime;

// ...

$date = new DateTimeImmutable('2021-02-20');
$clock = new SpecificTime($date);

// 2021-02-20
echo $clock->now()->format('Y-m-d');