PHPackages                             cornernote/yii-extended-date-time-formatting-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. cornernote/yii-extended-date-time-formatting-behavior

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

cornernote/yii-extended-date-time-formatting-behavior
=====================================================

\[Yii\] Behavior for CDateFormater that adds some methods for extending date&amp;time formatting.

010PHP

Since Jul 26Pushed 11y ago1 watchersCompare

[ Source](https://github.com/cornernote/yii-extended-date-time-formatting-behavior)[ Packagist](https://packagist.org/packages/cornernote/yii-extended-date-time-formatting-behavior)[ RSS](/packages/cornernote-yii-extended-date-time-formatting-behavior/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

**ExtendedDateTimeFormattingBehavior** adds some methods for extending date&amp;time formatting to *CDateFormatter* component.

Available formatters:

- `formatDateTimeReadable($timestamp, $dateWidth = 'medium', $timeWidth = 'medium')` formats date&amp;time with pattern **(Today|Yesterday|&lt;date&gt;), &lt;time&gt;**.
- **$dateWidth** is passed to `CDateFormatter::formatDateTime()` to format **&lt;date&gt;**
- **$timeWidth** is passed to `CDateFormatter::formatDateTime()` to format **&lt;time&gt;**
- `formatDateTimeInterval($timestamp, $precisely = false)` formats date&amp;time as a date&amp;time interval with pattern **&lt;metric value&gt; &lt;metric&gt; ago** or more complex **&lt;first metric value&gt; &lt;first metric&gt; and &lt;second metric value&gt; &lt;second metric&gt; ago**
- **$precisely** is setted to **true**, interval will be composed of two metrics.

**$timestamp** in both formatters can be unix timestamp (integer) or string to pass it to `strtotime()`.

---

How to use: attach this behavior to your dateFormatter instance.

For example, add this in your base controller class (`Controller`) and base console command class (`ConsoleCommand`):

```
    public function init()
    {
        parent::init();
        Yii::app()->dateFormatter->attachBehavior('ExtendedDateTimeFormatting', 'ext.ExtendedDateTimeFormattingBehavior.ExtendedDateTimeFormattingBehavior');
    }
```

---

Example:

```
echo Yii::app()->dateFormatter->formatDateTimeReadable('yesterday, 20:45:17');
```

returns **Yesterday, 8:45:17 PM20**

```
echo Yii::app()->dateFormatter->formatDateTimeInterval('yesterday, 20:45:17', true);
```

returns **20 hours and 54 minutes ago**

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 69.2% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/07c84a589344489e8195ec1c6afcfa3abcc23a73092ceaa4ca60da96355c4d16?d=identicon)[cornernote](/maintainers/cornernote)

---

Top Contributors

[![wapmorgan](https://avatars.githubusercontent.com/u/6000618?v=4)](https://github.com/wapmorgan "wapmorgan (9 commits)")[![cornernote](https://avatars.githubusercontent.com/u/51875?v=4)](https://github.com/cornernote "cornernote (4 commits)")

### Embed Badge

![Health badge](/badges/cornernote-yii-extended-date-time-formatting-behavior/health.svg)

```
[![Health](https://phpackages.com/badges/cornernote-yii-extended-date-time-formatting-behavior/health.svg)](https://phpackages.com/packages/cornernote-yii-extended-date-time-formatting-behavior)
```

PHPackages © 2026

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