PHPackages                             stigwue/happrox - 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. stigwue/happrox

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

stigwue/happrox
===============

Human approximation for numbers and durations.

v0.1.1(7y ago)1203MITPHP

Since Jul 29Pushed 7y ago1 watchersCompare

[ Source](https://github.com/stigwue/happrox)[ Packagist](https://packagist.org/packages/stigwue/happrox)[ RSS](/packages/stigwue-happrox/feed)WikiDiscussions master Synced today

READMEChangelog (2)DependenciesVersions (3)Used By (0)

Happrox
=======

[](#happrox)

Human approximation for numbers and durations. Think *98,760* to *98.7k*, *3,599s* to *58m 59s* as in Stackoverflow timestamps and Twitter stat counts.

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

[](#installation)

Installation is via composer.

```
composer require stigwue/happrox

```

Usage
-----

[](#usage)

There are only a few configurations needed: the number of decimal places for numbers, the datetime formatting and the maximum duration before direct datetime formats are used. In most cases, the default will do.

Also, to approximate numbers, just supply the *value*. For durations, the number of *seconds* will do. One can write custom functions to convert other datetime formats to seconds.

Note that, when supplied durations become greater than the set maximum approximation duration, the supplied duration will be treated as a UNIX timestamp and formatted accordingly. If this is not the case for you, *Happrox::setDurationBase()* should be set with an appropriate duration to correct the datetime (the default value is 0).

```
require_once(__DIR__ . '/happrox.php');

//set time zone, no where like home
date_default_timezone_set('Africa/Lagos');

$obj = new Happrox();

echo "Numbers\n";

$happrox = Happrox::number($obj, 10);
echo $happrox['value'] . ' -> ' . $happrox['happrox'] . "\n";
$happrox = Happrox::number($obj, 1010);
echo $happrox['value'] . ' -> ' . $happrox['happrox'] . "\n";
$happrox = Happrox::number($obj, 123456);
echo $happrox['value'] . ' -> ' . $happrox['happrox'] . "\n";
$happrox = Happrox::number($obj, 1010101);
echo $happrox['value'] . ' -> ' . $happrox['happrox'] . "\n";
$happrox = Happrox::number($obj, 12345678);
echo $happrox['value'] . ' -> ' . $happrox['happrox'] . "\n";
$happrox = Happrox::number($obj, 101010101010);
echo $happrox['value'] . ' -> ' . $happrox['happrox'] . "\n";

Happrox::setDurationBase($obj, time(NULL));

echo "Durations\n";

$happrox = Happrox::duration($obj, 36);
echo $happrox['value'] . ' -> ' . $happrox['happrox'] . "\n";
$happrox = Happrox::duration($obj, 3599);
echo $happrox['value'] . ' -> ' . $happrox['happrox'] . "\n";
$happrox = Happrox::duration($obj, 518400);
echo $happrox['value'] . ' -> ' . $happrox['happrox'] . "\n";
$happrox = Happrox::duration($obj, 604799);
echo $happrox['value'] . ' -> ' . $happrox['happrox'] . "\n";
$happrox = Happrox::duration($obj, 123456);
echo $happrox['value'] . ' -> ' . $happrox['happrox'] . "\n";
```

```
Numbers
10 -> 10
1010 -> 1.0k
123456 -> 123.5k
1010101 -> 1.0M
12345678 -> 12.3M
101010101010 -> 101.0B
Durations
36 -> 36s
3599 -> 59m 59s
518400 -> 6d
604799 -> Jul 22, 2018 7:32am
123456 -> 1d 10hr

```

To Do
-----

[](#to-do)

- Handle Indian style number approximations (lakh)?
- Introduce switches to format durations for local weekdays (marketdays). Need an array of ordered days and a specific day's assignment (1 Jan 1970 should do).

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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 ~39 days

Total

2

Last Release

2854d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5908154?v=4)[Stephen Igwue](/maintainers/stigwue)[@stigwue](https://github.com/stigwue)

---

Top Contributors

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

---

Tags

timedatenumberhumanapproximation

### Embed Badge

![Health badge](/badges/stigwue-happrox/health.svg)

```
[![Health](https://phpackages.com/badges/stigwue-happrox/health.svg)](https://phpackages.com/packages/stigwue-happrox)
```

###  Alternatives

[knplabs/knp-time-bundle

Making your dates and durations look sensible and descriptive

6239.3M51](/packages/knplabs-knp-time-bundle)[league/period

Time range API for PHP

7335.7M22](/packages/league-period)[brick/date-time

Date and time library

3623.6M94](/packages/brick-date-time)[aeon-php/calendar

PHP type safe, immutable calendar library

20410.2M16](/packages/aeon-php-calendar)[tplaner/when

Date/Calendar recursion library.

5261.1M7](/packages/tplaner-when)[florianv/business

DateTime calculations in business hours

360781.1k1](/packages/florianv-business)

PHPackages © 2026

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