easyconn/yii2-datetime-behavior

Initiates database date columns as DateTime PHP classes.

Installs: 7

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 2

Type:yii2-extension

1.0.0 2018-03-30 14:23 UTC

This package is auto-updated.

Last update: 2024-03-29 03:44:42 UTC


README

Initiates database date columns as DateTime PHP classes.

Installation

The preferred way to install this extension is through composer.

Either run

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

or add

"davidhirtz/yii2-datetime-behavior": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by adding it to your ActiveRecord behavior. If you don't set the attributes all "date" and "datetime" columns will be automatically selected.

use davidhirtz\yii\datetime\DateTimeBehavior;
public function behaviors()
{
	return [
		[
			'class'=>DateTimeBehavior::className(),
			//'attributes'=>['custom_attribute', 'another_attribute'],
		],
	];
}