permafrost-dev/expanded-dates

This package is abandoned and no longer maintained. No replacement package was suggested.

Expands a date from a single format to multiple formats

1.0.3 2019-08-10 00:01 UTC

This package is auto-updated.

Last update: 2021-07-06 01:28:34 UTC


README

Latest Version on Packagist Build Status Quality Score Total Downloads

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-dates

Usage

    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 test

License

The MIT License (MIT). Please see License File for more information.