Skip to content

expands a date string into an object containing several useful formats

License

Notifications You must be signed in to change notification settings

permafrost-dev/expanded-dates

Repository files navigation

Expanded Dates

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.

About

expands a date string into an object containing several useful formats

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages