vistag / human-readable
Convert numbers and seconds to the human readable format
Installs: 2 783
Dependents: 1
Suggesters: 0
Security: 0
Stars: 14
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^5.4 || ^7.0
Requires (Dev)
- jakub-onderka/php-parallel-lint: ^0.9.0
- phpunit/phpunit: ^4.7|^5.0
This package is not auto-updated.
Last update: 2024-12-22 06:05:45 UTC
README
Human readable numbers and time package
Installation
You can install this package via composer using this command:
composer require vistag/human-readable
Usage
Numbers
use Vistag\HumanReadable\ReadableNumber; $number = new ReadableNumber(550); $number->raw(); // 550 $number->short(); // 550 $number->long(); // 550 $number = new ReadableNumber(1515); $number->short(); // 1.5k $number->long(); // 1.51k $number = new ReadableNumber(155550); $number->short(); // 155k $number->long(); // 155.55k $number = new ReadableNumber(5999900); $number->short(); // 5.9M $number->long(); // 5.99M
See tests for more examples.
Seconds
use Vistag\HumanReadable\ReadableSeconds; $seconds = new ReadableSeconds(990); $seconds->raw(); // 990 $seconds->short(); // 990s $seconds->long(); // 16m 30s $seconds = new ReadableSeconds(1010); $seconds->short(); // 16m $seconds->long(); // 16m 50s $seconds = new ReadableSeconds(155550); $seconds->short(); // 151m $seconds->long(); // 2h 31m $seconds = new ReadableSeconds(5999900); $seconds->short(); // 27h $seconds->long(); // 27.6h
See tests for more examples.
Support
If you believe you have found an issue, please report it using the GitHub issue tracker, or better yet, fork the repository and submit a pull request.
If you're using this package, I'd love to hear your thoughts. Thanks!
License
The MIT License (MIT). Vistag.com