davidhirtz/yii2-datetime-behavior

Initiates database date columns as DateTime PHP classes.

Installs: 1 168

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 2

Open Issues: 0

Type:yii2-extension

v1.1.6 2022-08-07 09:03 UTC

This package is auto-updated.

Last update: 2024-10-07 13:25:55 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::class,
			//'attributes'=>['custom_attribute', 'another_attribute'],
		],
	];
}