2017 © Pedro Peláez
 

library nearest

Gives the nearest timestamp by X seconds

image

ricoli/nearest

Gives the nearest timestamp by X seconds

  • Friday, November 3, 2017
  • by ricoli
  • Repository
  • 2 Watchers
  • 2 Stars
  • 96 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

nearest

Build Status Total Downloads, (*1)

Gives the nearest timestamp by X seconds. Inspired by the ruby project with the same name., (*2)

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:, (*3)

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

Add it your your application!

Add to your composer.json:, (*4)

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

https://packagist.org/packages/ricoli/nearest, (*5)

The Versions

03/11 2017

dev-master

9999999-dev

Gives the nearest timestamp by X seconds

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Ricardo Oliveira

timestamp seconds nearest