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 today

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 52% of packages

Maintenance45

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

431d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/174406827?v=4)[Ted7021](/maintainers/Ted7021)[@Ted7021](https://github.com/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

[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.7k53](/packages/ecotone-ecotone)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M46](/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)
