An open API service indexing awesome lists of open source software.

https://github.com/labrodev/time-converter

PHP 8.1+ utility library that provides static helper methods to convert between seconds, minutes, and hours — built for simplicity and performance.
https://github.com/labrodev/time-converter

composer-library composer-package datetime labrodev php php-converter php-library php-package php-time php-utility php-utils php8 time-converter

Last synced: 7 months ago
JSON representation

PHP 8.1+ utility library that provides static helper methods to convert between seconds, minutes, and hours — built for simplicity and performance.

Awesome Lists containing this project

README

          

# PHP Time Converter

**Labrodev\TimeConverter** is a strict PHP 8.1+ utility library that provides static helper methods to convert between seconds, minutes, and hours — built for simplicity and performance.

## Features

- Convert seconds to minutes
- Convert hours and minutes into raw minute count
- Convert float-based minutes into integer format
- Convert hours (as float) into total minutes
- Fully static and type-safe class
- Lightweight, dependency-free implementation
- Includes PHPUnit and PHPStan support for testing and analysis

## Installation

```
composer require labrodev/time-converter
```

## Usage

```php
use Labrodev\TimeConverter\Converter;

// Convert seconds to minutes
Converter::secondsToMinutes(180); // 3.0

// Convert hours and minutes to raw minutes
Converter::timeToRawMinutes(2, 30); // 150

// Convert float minutes to integer
Converter::floatMinutesToInt(12.7); // 13

// Convert hours to minutes
Converter::hoursToMinutes(1.5); // 90
```

## Testing

To run tests:

```
composer install
composer test
```

## Static Analysis

To run static analysis using PHPStan:

```
composer install
composer analyse
```

> Configuration is located in `phpstan.neon.dist`

## Security

If you discover a security vulnerability within this package, **please contact us immediately at [contact@labrodev.com](mailto:contact@labrodev.com)**. All security-related issues will be handled privately and promptly.

## Credits

This package is maintained by **Labrodev** — Laravel & PHP development studio.
[https://github.com/labrodev](https://github.com/labrodev)

## Feedback

If you have any questions, suggestions, or have found an error — feel free to open an issue or contact us:
**contact@labrodev.com**

**License:** MIT