https://github.com/permafrost-dev/expanded-dates
expands a date string into an object containing several useful formats
https://github.com/permafrost-dev/expanded-dates
date-formatter dates relative-date relative-time
Last synced: 12 months ago
JSON representation
expands a date string into an object containing several useful formats
- Host: GitHub
- URL: https://github.com/permafrost-dev/expanded-dates
- Owner: permafrost-dev
- License: mit
- Created: 2019-08-03T15:31:29.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-10T17:46:46.000Z (almost 7 years ago)
- Last Synced: 2025-03-17T05:47:58.238Z (over 1 year ago)
- Topics: date-formatter, dates, relative-date, relative-time
- Language: PHP
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Expanded Dates
[](https://packagist.org/packages/permafrost-dev/expanded-packages)
[](https://travis-ci.org/permafrost-dev/expanded-packages)
[](https://scrutinizer-ci.com/g/permafrost-dev/expanded-packages)
[](https://packagist.org/packages/permafrost-dev/expanded-packages)
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:
```bash
composer require permafrost-dev/expanded-dates
```
## Usage
``` php
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
``` bash
composer test
```
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.