PHPackages                             ricoli/nearest - 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. ricoli/nearest

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

ricoli/nearest
==============

Gives the nearest timestamp by X seconds

2102PHPCI failing

Since Nov 3Pushed 8y ago2 watchersCompare

[ Source](https://github.com/ricoli/nearest)[ Packagist](https://packagist.org/packages/ricoli/nearest)[ RSS](/packages/ricoli-nearest/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

\#nearest

[![Build Status](https://camo.githubusercontent.com/fd25c87b8232208bd8f724921fb5ff77867dec1aa0e27b6d0feca7074c26b92e/68747470733a2f2f7472617669732d63692e6f72672f7269636f6c692f6e6561726573742e706e67)](https://travis-ci.org/ricoli/nearest) [![Total Downloads](https://camo.githubusercontent.com/ad37128427436e66350e045cbac25db39fd99144bd464d3488e7ef90e7f00d1c/68747470733a2f2f706f7365722e707567782e6f72672f7269636f6c692f6e6561726573742f646f776e6c6f6164732e706e67)](https://packagist.org/packages/ricoli/nearest)

Gives the nearest timestamp by X seconds. Inspired by the ruby project with the same name.

\##Example

```
$nearest = new \Ricoli\Nearest\Nearest();
$nearestTimestamp = $nearest->getNearestTimestamp(300, time());

```

Will give you the closest 5 minutes from now, defaulting to the PHP\_ROUND\_HALF\_UP rounding mode. So if the current time is 13:02:30, it would return 13:05:00 (in its timestamp form). Supports the following modes: PHP\_ROUND\_HALF\_UP, PHP\_ROUND\_HALF\_DOWN, Nearest::NEAREST\_CEIL, Nearest::NEAREST\_FLOOR. The mode can be provided as the third argument:

```
$nearest = new \Ricoli\Nearest\Nearest();
$nearestTimestamp = $nearest->getNearestTimestamp(300, time(), PHP_ROUND_HALF_DOWN);

```

\##Add it your your application!

Add to your composer.json:

```
"require": {
    ...
    "ricoli/nearest": "dev-master"
}

```

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ce900c614052702f1762a95fb9d342f5c5403634c5cefe2d1f4255585ba3b4fc?d=identicon)[ricoli](/maintainers/ricoli)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/ricoli-nearest/health.svg)

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

PHPackages © 2026

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