https://github.com/manchenkoff/timer-helper
'Timer' is a class to help build time interval value in seconds by object-oriented style
https://github.com/manchenkoff/timer-helper
datetime interval php php-helper time timestamp
Last synced: 5 months ago
JSON representation
'Timer' is a class to help build time interval value in seconds by object-oriented style
- Host: GitHub
- URL: https://github.com/manchenkoff/timer-helper
- Owner: manchenkoff
- License: mit
- Created: 2019-05-22T16:53:11.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-01-19T10:25:11.000Z (about 2 years ago)
- Last Synced: 2025-07-14T13:47:18.550Z (6 months ago)
- Topics: datetime, interval, php, php-helper, time, timestamp
- Language: PHP
- Homepage: https://packagist.org/packages/manchenkov/timer
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# Timer
[](https://packagist.org/packages/manchenkov/timer)
[](https://packagist.org/packages/manchenkov/timer)
[](https://packagist.org/packages/manchenkov/timer)
[](https://packagist.org/packages/manchenkov/timer)
**Timer** is a class to help build time interval value in seconds by object-oriented style
## Installation
You have to run following command to add a dependency to your project
```bash
composer require manchenkov/timer
```
or you can add this line to `require` section of `composer.json`
```
"manchenkov/timer": "*"
```
## Usage
```php
use Manchenkov\Timer\Timer;
$timer = Timer::get()->hours(5)->minutes(10)->seconds(34);
$intervalValue = $timer->asNumber(); // -> 18634 = 34 + (10 * 60) + (5 * 3600)
$intervalString = $timer->asString(); // -> 05:10:34
// or
$intervalString = (string)$timer; // -> 05:10:34
```
## Testing
To run test cases you should execute the following command
```bash
./vendor/bin/phpunit tests --testdox
```