2017 © Pedro Peláez
 

yii2-extension yii2-datetime-converter

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

image

bupy7/yii2-datetime-converter

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

  • Friday, February 5, 2016
  • by bupy7
  • Repository
  • 1 Watchers
  • 1 Stars
  • 439 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 3 % Grown

The README.md

yii2-datetime-converter

Latest Stable Version Total Downloads Latest Unstable Version License Build Status Coverage Status, (*1)

Converting date/time from display/save to save/display format., (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

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

or add, (*5)

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

to the require section of your composer.json file., (*6)

Usage

Add component to your config:, (*7)

'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, (*8)

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

You can add behavior of your model for converting date/time before save., (*9)

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., (*10)

The Versions

05/02 2016

dev-master

9999999-dev

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

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

extension yii2 date carbon formatter translator converter time datetime

05/02 2016

1.1.1

1.1.1.0

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

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

extension yii2 date carbon formatter translator converter time datetime

10/12 2015

1.1.0

1.1.0.0

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

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 date carbon formatter translator converter time datetime

23/07 2015

1.0.0

1.0.0.0

II DEVELOPING!

  Sources   Download

BSD-3-Clause

The Requires

 

extension yii2 date carbon formatter translator converter time datetime