dev-master
9999999-devGives the nearest timestamp by X seconds
MIT
The Requires
- php >=5.4.0
The Development Requires
by Ricardo Oliveira
timestamp seconds nearest
Wallogit.com
2017 © Pedro Peláez
Gives the nearest timestamp by X seconds
Gives the nearest timestamp by X seconds. Inspired by the ruby project with the same name., (*2)
$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 to your composer.json:, (*4)
"require": {
...
"ricoli/nearest": "dev-master"
}
https://packagist.org/packages/ricoli/nearest, (*5)
Gives the nearest timestamp by X seconds
MIT
timestamp seconds nearest