raggitech/laravel-readable

Laravel - Readable Number (Integer|decimal) & DateTime & Time Length & File Size.

1.0.1 2020-06-08 12:38 UTC

This package is auto-updated.

Last update: 2020-06-18 13:30:24 UTC


README

Latest Stable Version Total Downloads License

Laravel Readable provides a quick and easy functions & blade directives.

  • Number. (1,020,304,050,607,080)
  • HumanNumber. ( 77K || 77.4K || 77.37K )
  • Decimal. ( 60,708.547 )
  • 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 )
  • DateTime Length. ( 27 years - 1 week - 7 minutes - 7 seconds before )
  • File Size. ( 70 GB )

Install

Install the latest version using Composer:

$ composer require raggitech/laravel-readable

Usage

Readable has the following methods & directives:

ReadableNumber (int $number, string $delimiter = ',')
1,020,304,050,607,080

ReadableHumanNumber (int $number, bool $showDecimal = false, int $decimals = 0)
77K || 77.4K || 77.37K

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

ReadableDate ($date, string $timezone = null)

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

24 April 2020

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 ($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 ($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 (int $seconds, string $comma = ' ')
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

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
Full-Form + Comma => 27 years - 1 week - 7 minutes - 7 seconds before

ReadableSize (int $bytes)
70 GB

License

MIT license