PHPackages                             amrachraf6699/datify - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. amrachraf6699/datify

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

amrachraf6699/datify
====================

Automatic timestamp formatting helpers for Laravel created\_at and updated\_at columns.

v1.0.5(4mo ago)03MITPHPPHP ^8.0

Since Dec 28Pushed 4mo agoCompare

[ Source](https://github.com/amrachraf6699/Datify)[ Packagist](https://packagist.org/packages/amrachraf6699/datify)[ RSS](/packages/amrachraf6699-datify/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (7)Used By (0)

Datify for Laravel
==================

[](#datify-for-laravel)

Datify auto-formats `created_at` and `updated_at` across your Laravel models. Set a default display for each column, opt into extra variants (humanized, ISO, calendar, etc.), and customize the attribute naming pattern—all via a single config file.

Why Datify?
-----------

[](#why-datify)

- Consistent timestamp output without repeating `format()` everywhere.
- Drop-in trait: add to a base model to cover the whole project.
- Config-driven: toggle variants, set defaults per column, change attribute suffixes, or supply a custom PHP date format.

Requirements
------------

[](#requirements)

- PHP 8.0+
- Laravel 8-12 (illuminate/support, illuminate/database) — including Laravel 12

Installation
------------

[](#installation)

```
composer require amrachraf6699/datify
php artisan vendor:publish --tag=datify-config
```

Quick Start
-----------

[](#quick-start)

Add the trait to your base model (or any model you want to opt in):

```
use Datify\Concerns\HasDatifyTimestamps;

class Model extends \Illuminate\Database\Eloquent\Model
{
    use HasDatifyTimestamps;
}
```

Configuration (`config/datify.php`)
-----------------------------------

[](#configuration-configdatifyphp)

Key options (see inline comments in the config for details):

- Boolean toggles: `to_date`, `to_time`, `to_date_time`, `to_day_date_time`, `to_iso_8601`, `to_iso`, `to_human`, `to_short_human`, `to_calendar`.
- `custom`: PHP date format string used when `custom` is selected; if `null`, raw DB timestamp is returned.
- `suffix`: naming pattern for appended attributes; `{format}` becomes the format key without `to_`. Default `_{format}` yields `created_at_human`, `updated_at_iso_8601`, etc.
- `defaults`: per-column default format for `created_at` and `updated_at` when you access them normally.

Example Config
--------------

[](#example-config)

```
return [
    // Turn on extra accessors:
    'to_human' => true,
    'to_short_human' => true,
    'to_iso_8601' => true,
    'to_date_time' => true,

    // Custom naming (created_at.pretty, updated_at.pretty, etc.)
    'suffix' => '.{format}',

    // Custom format string (used when selecting 'custom')
    'custom' => 'd/m/Y H:i',

    // Default display for base attributes
    'defaults' => [
        'created_at' => 'to_human',
        'updated_at' => 'custom',
    ],
];
```

Attribute Outputs
-----------------

[](#attribute-outputs)

- Base attributes (`created_at`, `updated_at`): formatted using `defaults.created_at` / `defaults.updated_at`.
- Extra attributes: added only when the corresponding boolean toggle is `true`. Names follow `suffix` with `{format}` substituted (format key without `to_`).

Example Model Output
--------------------

[](#example-model-output)

Given `created_at = 2024-12-28 13:37:42` UTC, config with `suffix: '_{format}'`, `to_human: true`, `to_iso_8601: true`, `defaults.created_at: 'to_date_time'`:

```
$post = Post::first();

$post->created_at;           // "2024-12-28 13:37:42"
$post->created_at_human;     // "2 hours ago"
$post->created_at_iso_8601;  // "2024-12-28T13:37:42+00:00"
```

Using a Custom Format Default
-----------------------------

[](#using-a-custom-format-default)

```
// config/datify.php
'custom' => 'd/m/Y h:i A',
'defaults' => [
    'created_at' => 'custom',
    'updated_at' => 'custom',
],

// Later
$user->created_at; // "28/12/2024 01:37 PM"
```

Raw Database Values
-------------------

[](#raw-database-values)

- Use `$model->getRawOriginal('created_at')` or `->getRawOriginal('updated_at')` to bypass formatting.
- If `custom` is selected as the default and `custom` is `null`, Datify falls back to the raw DB timestamp string (e.g., `Y-m-d H:i:s`).

Integration Tips
----------------

[](#integration-tips)

- Add the trait to your base model to cover all models at once.
- Choose minimal toggles to avoid bloating serialized output; only enable the variants you need.
- When changing the `suffix`, remember it affects all appended attribute names; update API consumers accordingly.

Changelog &amp; Contributing
----------------------------

[](#changelog--contributing)

- Open a PR or issue at  once the repo is live.
- Please include Laravel/PHP versions and a reproduction snippet when filing bugs.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance74

Regular maintenance activity

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

6

Last Release

141d ago

PHP version history (2 changes)v1.0.0PHP ^8.1

v1.0.3PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/edccf2dc747c01b536a671aa552e587b5f6a595747ecbe77d44b95dd9ad1195a?d=identicon)[amrachraf6699](/maintainers/amrachraf6699)

---

Top Contributors

[![amrachraf6699](https://avatars.githubusercontent.com/u/168471094?v=4)](https://github.com/amrachraf6699 "amrachraf6699 (8 commits)")

### Embed Badge

![Health badge](/badges/amrachraf6699-datify/health.svg)

```
[![Health](https://phpackages.com/badges/amrachraf6699-datify/health.svg)](https://phpackages.com/packages/amrachraf6699-datify)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

20917.2M158](/packages/orchestra-canvas)[kirschbaum-development/commentions

A package to allow you to create comments, tag users and more

12369.2k](/packages/kirschbaum-development-commentions)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[glhd/special

1929.4k](/packages/glhd-special)[bjuppa/laravel-blog

Add blog functionality to your Laravel project

483.3k2](/packages/bjuppa-laravel-blog)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
