PHPackages                             radynsade/postgres-clock - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. radynsade/postgres-clock

ActiveLibrary[Database &amp; ORM](/categories/database)

radynsade/postgres-clock
========================

PSR-20 clock implementation backed by PostgreSQL server time.

v1.0.1(2d ago)10MITPHPPHP ^8.4.1

Since Aug 15Pushed todayCompare

[ Source](https://github.com/radynsade/postgres-clock)[ Packagist](https://packagist.org/packages/radynsade/postgres-clock)[ Docs](https://github.com/radynsade/postgres-clock)[ RSS](/packages/radynsade-postgres-clock/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (4)Versions (3)Used By (0)

Database Clock
==============

[](#database-clock)

A [PSR-20](https://www.php-fig.org/psr/psr-20/) clock implementation that reads the current time from a database server and returns it as an immutable UTC value.

The package supports MySQL, MariaDB, and PostgreSQL through PDO and native database extensions.

Requirements
------------

[](#requirements)

- PHP 8.4.1 or later (below PHP 9.0)
- A supported database server
- The extension required by the selected adapter:

AdapterRequired extensions`DatabaseClock\MySql\PdoClock``ext-pdo`, `ext-pdo_mysql``DatabaseClock\MySql\MysqliClock``ext-mysqli``DatabaseClock\PostgreSql\PdoClock``ext-pdo`, `ext-pdo_pgsql``DatabaseClock\PostgreSql\PgsqlClock``ext-pgsql`Installation
------------

[](#installation)

```
composer require radynsade/database-clock
```

Usage
-----

[](#usage)

All adapters implement `Psr\Clock\ClockInterface` and return a `DateTimeImmutable` instance in UTC.

### With PDO

[](#with-pdo)

```
use DatabaseClock\PostgreSql\PdoClock;
use PDO;

$connection = new PDO(
	'pgsql:host=localhost;dbname=app',
	'postgres',
	'secret',
);

$clock = new PdoClock($connection);
$currentTime = $clock->now();
```

### MySQL with MySQLi

[](#mysql-with-mysqli)

```
use DatabaseClock\MySql\MysqliClock;
use mysqli;

$connection = new mysqli(
	'localhost',
	'root',
	'secret',
	'app',
);

$clock = new MysqliClock($connection);
$currentTime = $clock->now();
```

### PostgreSQL with `ext-pgsql`

[](#postgresql-with-ext-pgsql)

```
use DatabaseClock\PostgreSql\PgsqlClock;
use RuntimeException;

$connection = pg_connect('host=localhost dbname=app user=postgres password=secret');

if ($connection === false) {
	throw new RuntimeException('Failed to connect to PostgreSQL.');
}

$clock = new PgsqlClock($connection);
$currentTime = $clock->now();
```

Testing
-------

[](#testing)

```
composer test
```

To include the PDO and Pgsql integration tests for PostgreSQL, provide a connection URL:

```
POSTGRES_CLOCK_TEST_CONNECTION='postgresql://postgres:secret@127.0.0.1:5432/test' composer test
```

To include the PDO and MySQLi integration tests for MySQL or MariaDB, provide a connection URL:

```
MYSQL_CLOCK_TEST_CONNECTION='mysql://root:secret@127.0.0.1:3306/test' composer test
```

License
-------

[](#license)

MIT

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance100

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/39616665?v=4)[Nikita Prokopenko](/maintainers/radynsade)[@radynsade](https://github.com/radynsade)

---

Top Contributors

[![radynsade](https://avatars.githubusercontent.com/u/39616665?v=4)](https://github.com/radynsade "radynsade (3 commits)")

---

Tags

clockmariadbmysqlphpphp-librarypostgrespostgresqlpsr-20databaseclockpsr-20postgresqlpostgrespdopgsqltime

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/radynsade-postgres-clock/health.svg)

```
[![Health](https://phpackages.com/badges/radynsade-postgres-clock/health.svg)](https://phpackages.com/packages/radynsade-postgres-clock)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k614.3M7.4k](/packages/doctrine-dbal)[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4573.2M41](/packages/aura-sqlquery)[aura/sql

A PDO extension that provides lazy connections, array quoting, query profiling, value binding, and convenience methods for common fetch styles. Because it extends PDO, existing code that uses PDO can use this without any changes to the existing code.

5662.7M60](/packages/aura-sql)[atlas/query

Object-oriented query builders and performers for MySQL, Postgres, SQLite, and SQLServer.

41260.2k7](/packages/atlas-query)[aura/sqlschema

Provides facilities to read table names and table columns from a database using PDO.

41245.4k4](/packages/aura-sqlschema)[delight-im/db

Safe and convenient SQL database access in a driver-agnostic way

46181.6k7](/packages/delight-im-db)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
