Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 20 days 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 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-19T10:25:11.000Z (12 months ago)
- Last Synced: 2024-10-12T10:47:37.311Z (3 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: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# Timer
[![Latest Stable Version](http://poser.pugx.org/manchenkov/timer/v)](https://packagist.org/packages/manchenkov/timer)
[![Total Downloads](http://poser.pugx.org/manchenkov/timer/downloads)](https://packagist.org/packages/manchenkov/timer)
[![License](http://poser.pugx.org/manchenkov/timer/license)](https://packagist.org/packages/manchenkov/timer)
[![PHP Version Require](http://poser.pugx.org/manchenkov/timer/require/php)](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
```