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
Requires
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-10-29 05:16:33 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'], ], ]; }