chrisharrison / clock
A PHP 7 clock interface.
Installs: 15 118
Dependents: 3
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: ^6.3
This package is auto-updated.
Last update: 2024-10-29 05:22:23 UTC
README
A PHP 7 clock interface.
Installation
Through Composer, obviously:
composer require chrisharrison/clock
Examples
Frozen clock (useful for testing)
$frozenClock = new \ChrisHarrison\Clock\FrozenClock(new \DateTime('1988-05-01 16:00:00')); echo $frozenClock->now()->format('Y-m-d H:i:s'); echo $frozenClock->now()->format('Y-m-d H:i:s'); echo $frozenClock->now()->format('Y-m-d H:i:s');
Outputs:
1988-05-01 16:00:00
1988-05-01 16:00:00
1988-05-01 16:00:00
System clock (has a hard dependency on the underlying operating system's clock)
$systemClock = new \ChrisHarrison\Clock\SystemClock; echo $systemClock->now()->format('Y-m-d H:i:s'); echo $systemClock->now()->format('Y-m-d H:i:s'); echo $systemClock->now()->format('Y-m-d H:i:s');
Outputs:
2017-10-01 20:43:22
2017-10-01 20:43:23
2017-10-01 20:43:24