PE
permafrost-dev/expanded-dates
expands a date string into an object containing several useful formats
Expanded Dates
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.
Installation
You can install the package via composer:
composer require permafrost-dev/expanded-datesUsage
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
)
)
Testing
composer testLicense
The MIT License (MIT). Please see License File for more information.
On this page
Languages
PHP100.0%
MIT License
Created August 3, 2019
Updated August 10, 2019