Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pointybeard/helpers-functions-time
A collection of functions used to manipulate time
https://github.com/pointybeard/helpers-functions-time
Last synced: 9 days ago
JSON representation
A collection of functions used to manipulate time
- Host: GitHub
- URL: https://github.com/pointybeard/helpers-functions-time
- Owner: pointybeard
- License: other
- Created: 2019-05-05T06:53:56.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-17T02:25:08.000Z (over 4 years ago)
- Last Synced: 2024-10-11T22:47:20.701Z (about 1 month ago)
- Language: PHP
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# PHP Helpers: Time Functions
- Version: v1.1.0
- Date: April 17 2020
- [Release notes](https://github.com/pointybeard/helpers-functions-time/blob/master/CHANGELOG.md)
- [GitHub repository](https://github.com/pointybeard/helpers-functions-time)A collection of functions used to manipulate time values
## Installation
This library is installed via [Composer](http://getcomposer.org/). To install, use `composer require pointybeard/helpers-functions-time` or add `"pointybeard/helpers-functions-time": "~1.1.0"` to your `composer.json` file.
And run composer to update your dependencies:
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update### Requirements
This library makes use of the [pointybeard/helpers-exceptions-readabletrace](https://github.com/pointybeard/helpers-exceptions-readabletrace) package. It is installed automatically via composer.
To include all the [PHP Helpers](https://github.com/pointybeard/helpers) packages on your project, use `composer require pointybeard/helpers` or add `"pointybeard/helpers": "~1.2.0"` to your composer file.
## Usage
This library is a collection convenience function for common tasks relating to time. They are included by the vendor autoloader automatically. The functions have a namespace of `pointybeard\Helpers\Functions\Time`
The following functions are provided:
- `human_readable_time(int $seconds, ?int $flags = FLAG_PAD_STRING | FLAG_INCLUDE_HOURS): string`
- `seconds_to_weeks($seconds): float`
- `seconds_to_days($seconds): float`
- `seconds_to_hours($seconds): float`
- `seconds_to_minutes($seconds): float`
- `weeks_to_seconds($weeks)`
- `days_to_seconds($days)`
- `hours_to_seconds($hours)`
- `minutes_to_seconds($minutes)`Example usage:
```php
getMessage());
}
// string(182) "Argument 1 passed to pointybeard\Helpers\Functions\Time\human_readable_time() must be of the type int, string given, called in /var/sources/helpers-functions-time/test.php on line 43"try {
Time\human_readable_time(-$seconds);
} catch (Exception $e) {
var_dump($e->getMessage());
}
// string(55) "Value provided for $seconds must be a positive integer."```
## Support
If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/pointybeard/helpers-functions-time/issues),
or better yet, fork the library and submit a pull request.## Contributing
We encourage you to contribute to this project. Please check out the [Contributing documentation](https://github.com/pointybeard/helpers-functions-time/blob/master/CONTRIBUTING.md) for guidelines about how to get involved.
## License
"PHP Helpers: Time Functions" is released under the [MIT License](http://www.opensource.org/licenses/MIT).