symfony/clock
最新稳定版本:v8.0.0
Composer 安装命令:
composer require symfony/clock
包简介
Decouples applications from the system clock
README 文档
README
Symfony Clock decouples applications from the system clock.
Getting Started
composer require symfony/clock
use Symfony\Component\Clock\NativeClock; use Symfony\Component\Clock\ClockInterface; class MyClockSensitiveClass { public function __construct( private ClockInterface $clock, ) { // Only if you need to force a timezone: //$this->clock = $clock->withTimeZone('UTC'); } public function doSomething() { $now = $this->clock->now(); // [...] do something with $now, which is a \DateTimeImmutable object $this->clock->sleep(2.5); // Pause execution for 2.5 seconds } } $clock = new NativeClock(); $service = new MyClockSensitiveClass($clock); $service->doSomething();
Resources
统计信息
- 总下载量: 142.48M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 424
- 点击次数: 1
- 依赖项目数: 145
- 推荐数: 3
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04