kikimor/yii-mysql-datetime-behavior

There is no license information available for the latest version (1.1.2) of this package.

MySQL datetime behavior for Yii-1

Installs: 49

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/kikimor/yii-mysql-datetime-behavior

1.1.2 2015-02-25 16:25 UTC

This package is auto-updated.

Last update: 2025-10-08 07:52:09 UTC


README

What is it?

Automatically converts date and datetime fields between ActiveRecord model and MySQL database for Yii framework.

How to instal?

composer require kikimor/yii-mysql-datetime-behavior dev-master

How to configure?

<?php
use Kikimor\MySQLDateTimeBehavior\MySQLDateTimeBehavior;
...
class model extends \CActiveRecord
{
  public function behaviors()
  {
  	return array_merge(parent::behaviors(), [
  		'DateTimeBehavior' => [
  		  'class' => MySQLDateTimeBehavior::class, 
  		  'dateFormat' => 'd.m.Y', // by default
  		  'dateTimeFormat' => 'd.m.Y H:i', // by default
  		],
  	]);
  }
}

How to use?

$model = Model::model()->findByPk(1);
echo $model->date; // 25.02.2015
$model->date = '26.02.2015';
$model->save();