tm / time-conversion
Convert, compare and operate with time in different units.
Installs: 63
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=5.6.0
Requires (Dev)
- codeclimate/php-test-reporter: ^0.3.2
- tm/tooly-composer-script: ^1.2
This package is auto-updated.
Last update: 2021-06-11 20:37:45 UTC
README
Convert, compare and operate with time in different unit's.
Features
- Conversion between different time unit's
- Support for comparing different time unit's like equals or greaterThan
- Support for math operations like add and subtract
Example
use TM\TimeConversion\Time;
use TM\TimeConversion\Unit;
// convert
$tenWeeks = Time::fromValue(10.0, Unit::WEEK);
$tenWeeksInDays = $tenWeeks->convert(Unit::DAY);
echo $tenWeeksInDays->getAmount(); // 70
// compare
var_dump($tenWeeks->equals($tenWeeksInDays)); // true
// subtract
echo $tenWeekInDays->subtract(Time::fromValue(10, Unit::DAY)); // 60
For more and advanced examples look into the examples directory.
Requirements
- PHP >= 5.6
- Composer
Install
composer require tm/time-conversion ^1.0
Contributing
Please refer to CONTRIBUTING.md for information on how to contribute.