PHPackages                             vladyslav-dyba/server-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. vladyslav-dyba/server-clock

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

vladyslav-dyba/server-clock
===========================

Provide correct server time based on its external IP

1.2(1y ago)111PHPPHP ^8.1

Since Apr 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/DybaVladyslav/server-clock)[ Packagist](https://packagist.org/packages/vladyslav-dyba/server-clock)[ RSS](/packages/vladyslav-dyba-server-clock/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

ServerClock package
===================

[](#serverclock-package)

[![Packagist](https://camo.githubusercontent.com/a638dd59f77301db8fa982959cb7d23d63fa07f31475842e499ce1de7ae6a77f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f796f75722d76656e646f722f7061636b6167652d6e616d652e737667)](https://packagist.org/packages/your-vendor/package-name)

Provide correct server time based on its external IP

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [TestRun](#test-run)
- [Usage](#usage)
- [Structure](#structure)
- [Configuration](#configuration)

Installation
------------

[](#installation)

### Composer Installation

[](#composer-installation)

To install the package, you can use Composer:

```
composer require vladyslav-dyba/server-clock
```

This will add the package to your composer.json file and download it into the vendor directory. Manual Installation

In case you want to include it manually, you can also follow these steps:

```
 - Download the package files.
 - Include the Composer autoloader in your project:

```

```
require 'vendor/autoload.php';
```

Test run
--------

[](#test-run)

Once you clone the package sepparetly, you can perform a test run to get local time based on an IP

To get local time for specific IP

```
  php ./bin/console.php 8.8.8.8
  php ./vendor/vladyslav-dyba/server-clock/bin/console.php 8.8.8.8
```

To get local time for external server IP

```
  php ./bin/console.php
  php ./vendor/vladyslav-dyba/server-clock/bin/console.php
```

Usage
-----

[](#usage)

Here, explain how to use your package with practical examples. Provide some basic functionality and advanced use cases.

To get a local time of the external server IP:

```
// Include the Composer autoloader
require 'vendor/autoload.php';

// IpSource object provides an IP for the next steps
$ipSource = new ExternalIpSource(IpInfoDataProviderFactory::make());

// Source of time
// Current example works based on defined IP
// Though, a client of the library can use its own implementation for TimeSourceDataProviderInterface
$timeSource = new DefaultTimeSource(TimeApiDataProviderFactory::make($ipSource));

// ServerClock is the core of the library
// It provides time based on TimeSourceInterface
// As well, a client of the library can use its own implementation for TimeSourceInterface

$serverClock = new ServerClock($timeSource);
$time = $serverClock->now();

echo $time->format(DateTime::ATOM) . "\n";
```

To get a local time of the provided a specific IP:

```
// Include the Composer autoloader
require 'vendor/autoload.php';

// Receiving a specific IP
$ip = $argv[1];

// IpSource object provides an IP for the next steps
$ipSource = new CustomIpSource($ip);

// Source of time
// Current example works based on defined IP
// Though, a client of the library can use its own implementation for TimeSourceDataProviderInterface
$timeSource = new DefaultTimeSource(TimeApiDataProviderFactory::make($ipSource));

// ServerClock is the core of the library
// It provides time based on TimeSourceInterface
// As well, a client of the library can use its own implementation for TimeSourceInterface

$serverClock = new ServerClock($timeSource);
$time = $serverClock->now();

echo $time->format(DateTime::ATOM) . "\n";
```

Structure
---------

[](#structure)

### Core

[](#core)

The core of the package is `ServerClock` object that implements `TimeSourceInterface` interface

### TimeSource

[](#timesource)

`ServerClock` gets a time from a `$timeSource` that implements `TimeSourceInterface`

Package has only one basic implementation of the `TimeSourceInterface` - `DefaultTimeSource`and its TimeSourse DataProvider: [TimeApi](https://timeapi.io) service

Client can substitute the DataProvider with their own solution that implements the `TimeSourceInterface`

### IpSource

[](#ipsource)

Since `TimeSource` works based on an IP information, `IpSourceInterface` implementation has to be provided.

Package has two basic implementation of the `IpSourceInterface`:

- `CustomIpSource` - provides any specific IP address
- `ExternalIpSource` - uses [IpInfo](https://ipinfo.io/) service as IpSource DataProvider to get and provide the external server IP

Configuration
-------------

[](#configuration)

Regardless, the package has its own `TimeSourceInterface` and `IpSourceInterface` implementations,

there is no any configuration that can be applied for the package because the package was created with minimum dependencies and its the primary approach to configure the package is substituting the interfaces implementations on a client side

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance43

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

Unknown

Total

1

Last Release

449d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/104162619?v=4)[Dyba Vladyslav](/maintainers/DybaVladyslav)[@DybaVladyslav](https://github.com/DybaVladyslav)

---

Top Contributors

[![DybaVladyslav](https://avatars.githubusercontent.com/u/104162619?v=4)](https://github.com/DybaVladyslav "DybaVladyslav (19 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vladyslav-dyba-server-clock/health.svg)

```
[![Health](https://phpackages.com/badges/vladyslav-dyba-server-clock/health.svg)](https://phpackages.com/packages/vladyslav-dyba-server-clock)
```

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

564576.7k52](/packages/ecotone-ecotone)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M47](/packages/tencentcloud-tencentcloud-sdk-php)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)

PHPackages © 2026

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