davidhirtz / yii2-datetime-behavior
Initiates database date columns as DateTime PHP classes.
Installs: 1 393
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 2
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-12-07 13:59:54 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'], ], ]; }