PHPackages                             bupy7/yii2-datetime-converter - 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. bupy7/yii2-datetime-converter

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

bupy7/yii2-datetime-converter
=============================

Converting date and/or time from saving format to display and converse.

1.1.1(10y ago)11.5k↓50%1BSD-3-ClausePHP

Since Jul 23Pushed 10y ago1 watchersCompare

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

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

yii2-datetime-converter
=======================

[](#yii2-datetime-converter)

[![Latest Stable Version](https://camo.githubusercontent.com/15c3769d59e8bea24e09a96fa763df5c778201a96120f6b6590f41f2a43ce459/68747470733a2f2f706f7365722e707567782e6f72672f62757079372f796969322d6461746574696d652d636f6e7665727465722f762f737461626c65)](https://packagist.org/packages/bupy7/yii2-datetime-converter)[![Total Downloads](https://camo.githubusercontent.com/23093f45a7166dfc9a5da41a3a3019ae1874b40daf43678ca3c360ea0e79d55e/68747470733a2f2f706f7365722e707567782e6f72672f62757079372f796969322d6461746574696d652d636f6e7665727465722f646f776e6c6f616473)](https://packagist.org/packages/bupy7/yii2-datetime-converter)[![Latest Unstable Version](https://camo.githubusercontent.com/4e5e194152a2dd90a97ed5c0a8b5dda67a2e6dbde8844a122df3bdeae48b49e6/68747470733a2f2f706f7365722e707567782e6f72672f62757079372f796969322d6461746574696d652d636f6e7665727465722f762f756e737461626c65)](https://packagist.org/packages/bupy7/yii2-datetime-converter)[![License](https://camo.githubusercontent.com/d9f8b96ee3f8a5bc8756b80c3084ec17096c7cbf058af123d1a4f436b6ac08cc/68747470733a2f2f706f7365722e707567782e6f72672f62757079372f796969322d6461746574696d652d636f6e7665727465722f6c6963656e7365)](https://packagist.org/packages/bupy7/yii2-datetime-converter)[![Build Status](https://camo.githubusercontent.com/e2b40da6df7cc99b72e3fc77af9636ec63455d622034a1e2b21a4dba4ad70b39/68747470733a2f2f7472617669732d63692e6f72672f62757079372f796969322d6461746574696d652d636f6e7665727465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/bupy7/yii2-datetime-converter)[![Coverage Status](https://camo.githubusercontent.com/c518ac487ee73610180f56dacc4793ca879ba73713eb6d4b3043bc2fbc78856c/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f62757079372f796969322d6461746574696d652d636f6e7665727465722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/bupy7/yii2-datetime-converter?branch=master)

Converting date/time from display/save to save/display format.

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist bupy7/yii2-datetime-converter "*"

```

or add

```
"bupy7/yii2-datetime-converter": "*"

```

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

Usage
-----

[](#usage)

Add component to your config:

```
'dtConverter' => [
    'class' => 'bupy7\datetime\converter\Converter',
    // 'saveTimeZone' => 'UTC' - by default
    // 'saveDate' => 'php:Y-m-d' - by default
    // 'saveTime' => 'php:H:i:s' - by default
    // 'saveDateTime' => 'php:U' - by default
    // add format patterns if need for your locales (by default uses `en`)
    'patterns' => [
        'ru' => [
            'displayTimeZone' => 'Europe/Moscow',
            'displayDate' => 'php:d.m.Y',
            'displayTime' => 'php:H:i',
            'displayDateTime' => 'php:d.m.Y, H:i',
        ],
    ],
],
```

```
$datetime = 2015-06-07 12:45:00;
echo Yii::$app->dtConverter->toDisplayDateTime($datetime);
```

or

```
$datetime = new DateTime('now');
echo Yii::$app->dtConverter->toDisplayDateTime($datetime);
```

You can add behavior of your model for converting date/time before save.

```
use bupy7\datetime\converter\ConverterBehavior;

public function behaviors()
{
    return [
        // converter date/time before save
        [
            'class' => ConverterBehavior::className(),
            'type' => ConverterBehavior::TYPE_DATE_TIME,
            'to' => ConverterBehavior::TO_SAVE,
            'attributes' => [
                self::EVENT_BEFORE_SAVE => ['attribute_1', 'attribute_2'],
            ],
        ],
    ];
}
```

\##License

yii2-grid is released under the BSD 3-Clause License.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

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

Total

3

Last Release

3749d ago

### Community

Maintainers

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

---

Top Contributors

[![bupy7](https://avatars.githubusercontent.com/u/5145037?v=4)](https://github.com/bupy7 "bupy7 (40 commits)")

---

Tags

formatterdatetimeconvertertimedatecarbonyii2extensiontranslator

### Embed Badge

![Health badge](/badges/bupy7-yii2-datetime-converter/health.svg)

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

###  Alternatives

[kartik-v/yii2-date-range

An advanced Yii 2 date range picker input for based on bootstrap-daterangepicker plugin.

894.4M42](/packages/kartik-v-yii2-date-range)[kartik-v/php-date-formatter

A Javascript datetime formatting and manipulation library using PHP date-time formats.

461.5M3](/packages/kartik-v-php-date-formatter)

PHPackages © 2026

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