

GitHub - symfony/clock: Decouples applications from the system clock
source link: https://github.com/symfony/clock
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Clock Component
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
Recommend
-
186
Symfony Demo Application The "Symfony Demo Application" is a reference application created to show how to develop applications following the Symfony Best Practi...
-
102
Rector - Instant Upgrades and Automated Refactoring Rector instantly upgrades and refactors the PHP code of your application. It can help you in 2 major areas: 1. Instant Upgrades Rector now supports upgrades from PHP 5.3...
-
154
The Symfony MakerBundle The MakerBundle is the fastest way to generate the most common code you'll need in a Symfony app: commands, controllers, form classes, event subscribers and more! This bundle is an alternative to
-
185
Symfony Recipes Symfony recipes allow the automation of Composer packages configuration via the Symfony Flex Composer plugin. This repository contains "official" recipes...
-
83
-
116
Symfony Demo Application The "Symfony Demo Application" is a reference application created to show how to develop applications following the Symfony Best Practi...
-
46
Do you take care of 2 or more projects on the same framework? Do you upgrade them both to the newest version of the framework from time to time?Or maybe you're successful, you grow and have 10 such projects.Today I'll show you how to maintain sp...
-
12
Summary Receiving FLEXlm Error -88,309: System Clock Has Been Set Back Synopsis When attempting to checkout a license, the following FLEXlm Error is received: -88,309: System clock has been set back. How do can this...
-
28
-
8
Windows 11 will soon let you enable seconds in system tray clock...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK