pekkis / clock
A very simple clock abstraction
Installs: 3 445
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=5.3.3
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2024-08-31 15:07:17 UTC
README
A really simple clock abstraction library for PHP.
Usage
<?php namespace Pekkis\Clock\Example; require_once __DIR__ . '/../vendor/autoload.php'; use Pekkis\Clock\ClockProvider; use Pekkis\Clock\FixedClock; use DateTime; // Real system clock, returns actual time $time = ClockProvider::getClock()->getTime(); var_dump($time); // Fixed clock (for testing for example) ClockProvider::setClock(new FixedClock(new DateTime('1978-03-21'))); $time = ClockProvider::getClock()->getTime(); var_dump($time); // Get time as datetime object $time = ClockProvider::getClock()->getDateTime(); var_dump($time->format('Y-m-d H:i:s'));