PHPackages                             ted7021/geo-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. ted7021/geo-clock

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

ted7021/geo-clock
=================

PHP clock based on external IP and timezone providers

v1.0.0(1y ago)01MITPHPPHP ^8.2

Since Apr 29Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Ted7021/geo-clock)[ Packagist](https://packagist.org/packages/ted7021/geo-clock)[ RSS](/packages/ted7021-geo-clock/feed)WikiDiscussions main Synced 1mo ago

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

GeoClock
========

[](#geoclock)

**GeoClock** is a lightweight PHP library that implements [PSR-20 ClockInterface](https://www.php-fig.org/psr/psr-20/) and returns the current time based on your server’s external IP address.

It supports multiple external providers with automatic fallback if the first one fails.

---

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

[](#installation)

```
composer require ted7021/geo-clock
```

---

Features
--------

[](#features)

- Returns `DateTimeImmutable` based on actual timezone from IP.
- Uses external providers like [WorldTimeAPI](https://worldtimeapi.org), [TimeAPI.io](https://timeapi.io), [ipgeolocation.io](https://ipgeolocation.io).
- Easily extendable: implement your own provider.
- PSR-20 compatible (`ClockInterface`).

---

Usage
-----

[](#usage)

```
use GeoClock\GeoClockFactory;

$clock = GeoClockFactory::create();

echo $clock->now()->format('Y-m-d H:i:s');
```

Want to specify IP?

```
$clock = GeoClockFactory::create('8.8.8.8');
```

---

Advanced usage with custom providers
------------------------------------

[](#advanced-usage-with-custom-providers)

```
use GeoClock\GeoClockFactory;
use GeoClock\Provider\WorldTimeApiProvider;

$clock = GeoClockFactory::createWithProviders([
    new WorldTimeApiProvider(),
]);

echo $clock->now()->format('Y-m-d H:i:s');
```

---

Providers
---------

[](#providers)

GeoClock includes the following providers:

ProviderRequires API key?`WorldTimeApiProvider`❌ No`TimeApiProvider`❌ No`IpGeolocationProvider`✅ Yes---

Configuration: Timeout and Retries
----------------------------------

[](#configuration-timeout-and-retries)

Each provider supports configurable timeout and retries:

- **Timeout**: maximum number of seconds to wait for a response (default `5.0` seconds).
- **Retries**: number of retry attempts on network errors (default `3` retries).

### Example: Custom timeout and retries

[](#example-custom-timeout-and-retries)

```
use GeoClock\Provider\WorldTimeApiProvider;

// Create a provider with 10 seconds timeout and 5 retries
$provider = new WorldTimeApiProvider(timeout: 10.0, maxRetries: 5);
```

Usage with API Key
------------------

[](#usage-with-api-key)

Some providers require an API key, for example, [ipgeolocation.io](https://ipgeolocation.io).

### Example: Using IpGeolocationProvider

[](#example-using-ipgeolocationprovider)

```
use GeoClock\GeoClockFactory;
use GeoClock\Provider\IpGeolocationProvider;

// Create provider with your API key
$provider = new IpGeolocationProvider('your-api-key-here');

// Create clock using custom provider
$clock = GeoClockFactory::createWithProviders([$provider]);

echo $clock->now()->format('Y-m-d H:i:s');
```

---

Testing
-------

[](#testing)

```
vendor/bin/phpunit
```

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

[](#requirements)

- PHP 8.2+
- ext-curl
- Composer

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance48

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

385d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/83d2012fafb5ca823473794c4c5f8adf02fa807fd0ede38b432bda2b59697849?d=identicon)[Ted7021](/maintainers/Ted7021)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ted7021-geo-clock/health.svg)

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

###  Alternatives

[ecotone/ecotone

Supporting you in building DDD, CQRS, Event Sourcing applications with ease.

558549.8k17](/packages/ecotone-ecotone)[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[dhlparcel/magento2-plugin

DHL Parcel plugin for Magento 2

11180.5k2](/packages/dhlparcel-magento2-plugin)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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