PHPackages                             maddoger/yii2-datetime-behavior - 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. maddoger/yii2-datetime-behavior

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

maddoger/yii2-datetime-behavior
===============================

Yii2 DateTime Behavior

v2.0.0(7y ago)03201MITPHP

Since Nov 5Pushed 7y agoCompare

[ Source](https://github.com/maddoger/yii2-datetime-behavior)[ Packagist](https://packagist.org/packages/maddoger/yii2-datetime-behavior)[ RSS](/packages/maddoger-yii2-datetime-behavior/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (1)

Yii2 DateTime formatting behavior
=================================

[](#yii2-datetime-formatting-behavior)

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist maddoger/yii2-datetime-behavior "*"

```

or add

```
"maddoger/yii2-datetime-behavior": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

For datetime format and timezone conversation you can use `DateTimeBehavior`.

In model behaviors for timestamp field:

```
[
    'class' => DateTimeBehavior::className(),
    'attributes' => ['published_at'],
    'originalFormat' => 'U', //original format
    'originalTimeZone' => 'UTC', //original timezone

    'timeZone' => 'Europe/London', //local timezone
    'format' => 'datetime', //local format, Formatter format
]
```

Now you can use `published_at` as original attribute and `published_at_local` as user read-write attribute.

For date fields:

```
[
    'class' => DateTimeBehavior::className(),
    'attributes' => ['birth_date'],
    'originalFormat' => 'Y-m-d',
    'format' => 'date',
    'timeZone' => 'UTC',
]
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

 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 ~281 days

Total

3

Last Release

2912d ago

Major Versions

v1.0.1 → v2.0.02018-05-21

### Community

Maintainers

![](https://www.gravatar.com/avatar/09bde1fb9f0bb0ef7e7b4e6d7d1e346b2c2f1b076bd757ef85722abb37a98000?d=identicon)[maddoger](/maintainers/maddoger)

---

Top Contributors

[![maddoger](https://avatars.githubusercontent.com/u/6214206?v=4)](https://github.com/maddoger "maddoger (3 commits)")

---

Tags

yii2extension

### Embed Badge

![Health badge](/badges/maddoger-yii2-datetime-behavior/health.svg)

```
[![Health](https://phpackages.com/badges/maddoger-yii2-datetime-behavior/health.svg)](https://phpackages.com/packages/maddoger-yii2-datetime-behavior)
```

###  Alternatives

[vyants/yii2-daemon

Extension provides functionality for simple daemons creation and control

7859.0k](/packages/vyants-yii2-daemon)[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)[richardfan1126/yii2-js-register

Yii2 widget to register JS into view

1357.2k7](/packages/richardfan1126-yii2-js-register)

PHPackages © 2026

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