Readable

Readable

Readable provides a quick and easy functions & blade directives.

Moamen Eltouny (Raggi)
PHP Version : >= 7.2 Laravel Version : >= 6.0 License Support
Source Packagist Version Packagist Downloads

- Number. (1,020,304,050,607,080)

- NumberToString. ( seven thousand seven hundred twenty-one ) {PHP Extension intl}

- HumanNumber. ( 77K || 77.4K || 77.37K )

- Decimal. ( 60,708.547 )

- DecInt. ( 70.00 => 70 || 70.07 )

- Date. ( 24 April 2020 )

- Time. ( 15:20 || 15:20:22 || 03:20 PM || 03:20:22 PM )

- DateTime. ( Friday, April 24, 2020 05:20 PM )

- DateTime Difference. ( 27 years before )

- Time Length. ( 4 years 7 months 1 week 3 days 9 hours 50 minutes 10 seconds )

- Short Time Length. ( 4y 7m 1w 3d 9h 50m 10s )

- DateTime Length. ( 27 years - 1 week - 7 minutes - 7 seconds before )

- File Size. ( 70 GB )

Install

Install the latest version using Composer

composer require pharaonic/laravel-readable
Usage

ReadableNumber

ReadableNumber (int $number, string $delimiter = ',')

1,020,304,050,607,080

ReadableNumberToString

ReadableNumberToString($input, string $lang = 'en')

EN => seven thousand seven hundred twenty-one
AR => سبعة آلاف و سبعة مائة و واحد و عشرون

ReadableHumanNumber

ReadableHumanNumber (int $number, bool $showDecimal = false, int $decimals = 0)

77K || 77.4K || 77.37K

ReadableDecimal

ReadableDecimal ($number, int $decimals = 2, , string $point = '.', string $delimiter = ',')

60,708.54

ReadableDecInt

ReadableDecInt ($number, int $decimals = 2, , string $point = '.', string $delimiter = ',')

70 || 70.7

ReadableDate

ReadableDate ($date, string $timezone = null)

$date = '24-04-2020' || Carbon Instance

24 April 2020

ReadableTime

ReadableTime ($time, $is12Hours = false, bool $hasSeconds = false, string $timezone = null)

$time = '15:20:22' || Carbon Instance

Has Seconds 15:20:22 || 03:20:22 PM
Hasn't Seconds 15:20 || 03:20 PM

ReadableDateTime

ReadableDateTime ($datetime, $is12Hours = false, bool $hasSeconds = false, string $timezone = null)

$datetime = '24-04-2020 17:20:32' || Carbon Instance

12Hours + Has Seconds => Friday, April 24, 2020 05:20:32 PM

ReadableDiffDateTime

ReadableDiffDateTime ($oldDateTime, $newDateTime = null, string $timezone = null)

$oldDateTime = '24-04-2020 17:20:32' || Carbon Instance $newDateTime = '24-04-2020 17:20:32' || Carbon Instance || null (now)

27 years before

ReadableTimeLength

ReadableTimeLength (int $seconds, string $comma = ' ', bool $short = false)

4 years 7 months 1 week 3 days 9 hours 50 minutes 10 seconds
Comma => 4 years - 7 months - 1 week - 3 days - 9 hours - 50 minutes - 10 seconds
Short => 4y 7m 1w 3d 9h 50m 10s

ReadableDateTimeLength

ReadableDateTimeLength ($oldDateTime, $newDateTime = null, bool $fullForm = false, string $comma = ' ', string $timezone = null)

$oldDateTime = '24-04-2020 17:20:32' || Carbon Instance $newDateTime = '24-04-2020 17:20:32' || Carbon Instance || null (now)

Short-Form => 27 years before

ReadableSize

ReadableSize (int $bytes, bool $decimal = true)

70 GB