This package takes an input string of a date (or a Carbon instance,) and expands it into an object containing several common formats, such as relative time and age in seconds, minutes, days, etc. See below for an example.
You can install the package via composer:
composer require permafrost-dev/expanded-dates
include __DIR__.'/../vendor/autoload.php';
$dateOne = ExpandedDate::create(Carbon::now()->subSeconds(35));
print_r($ed1);
Expands to an ExpandedDate object:
Permafrost\ExpandedDates\ExpandedDate Object
(
[value] => 2019-08-09T19:43:10-04:00
[relative] => 35 seconds ago
[formatted] => Aug 9, 2019
[time] => 7:43 PM
[timestamp] => 1565394190
[day] => Friday
[age] => stdClass Object
(
[seconds] => 35
[minutes] => 0
[hours] => 0
[days] => 0
[weeks] => 0
)
)
composer test
The MIT License (MIT). Please see License File for more information.