https://github.com/chrisdicarlo/eloquent-human-timestamps
Automatic human timestamps for Laravel Eloquent models.
https://github.com/chrisdicarlo/eloquent-human-timestamps
eloquent laravel timestamp
Last synced: about 1 month ago
JSON representation
Automatic human timestamps for Laravel Eloquent models.
- Host: GitHub
- URL: https://github.com/chrisdicarlo/eloquent-human-timestamps
- Owner: chrisdicarlo
- License: mit
- Created: 2020-10-15T22:23:43.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-02-09T20:45:20.000Z (3 months ago)
- Last Synced: 2025-04-09T15:07:33.683Z (about 1 month ago)
- Topics: eloquent, laravel, timestamp
- Language: PHP
- Homepage:
- Size: 79.1 KB
- Stars: 36
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.MD
- License: LICENSE
Awesome Lists containing this project
README
# Automatic human timestamp properties in Laravel
This package provides a trait you can add to an Eloquent model that will automatically create human-readable timestamp diffs using Carbon.
[](https://packagist.org/packages/chrisdicarlo/eloquent-human-timestamps)




[](https://packagist.org/packages/chrisdicarlo/eloquent-human-timestamps)## Version Compatibility
| Laravel | PHP | Package Version |
| ------- | --- | --------------- |
| 6 | 8.0, 7.4, 7.3 | 2 |
| 7 | 8.0, 7.4, 7.3 | 2 |
| 8 | 8.1, 8.0, 7.4, 7.3 | 3 |
| 9 | 8.1, 8.0 | 4 |
| 10 | 8.1, 8.2, 8.3, 8.4 | 5 |
| 11 | 8.2, 8.3, 8.4 | 6 |## Installation
To install the package run:
```
composer require chrisdicarlo/eloquent-human-timestamps
```## Setup
Add the ChrisDiCarlo\EloquentHumanTimestamps\HumanTimestamps trait to a model that has timestamp columns, e.g.:
```
use ChrisDiCarlo\EloquentHumanTimestamps\HumanTimestamps;
class Foobar
{use HumanTimestamps;
...
}
```## Usage
To get the human-readable attribute, simply retrieve the timestamp normally but append **_for_humans** to the name, e.g. created_at_for_humans, updated_at_for_humans.