Skip to content

YetOpen/i18n-datetime-behavior

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 

Repository files navigation

i18n-datetime-behavior

Yii i18n-datetime-behavior extension Sourced from version 1.1 of http://www.yiiframework.com/extension/i18n-datetime-behavior/

Author: Ricardo Grana [email protected], [email protected]

This extension is a behavior that can be used in models to allow them to automatically parse and format i18N date formats.

The behavior scans for date and datetime fields in the model attributes, and do the conversions needed.

Documentation

Requirements

Yii 1.0.9 or above You need to have defined your desired language at the entry script. Installation

Extract the release file and put it under protected/extensions

Usage

In you model, add the following code:

public function behaviors()
{
    return array('datetimeI18NBehavior' => array('class' => 'ext.DateTimeI18NBehavior')); // 'ext' is in Yii 1.0.8 version. For early versions, use 'application.extensions' instead.
}

IMPORTANT! This behavior changes afterFind and beforeSave events. If your model have to have coding, please, don't forget to add the parent reference:

protected function beforeSave(){
    if (!parent::beforeSave()) return false;
    ....your code
}

The same for afterFind method. Otherwise, this behavior will not make effect.

Releases

No releases published

Packages

No packages published

Languages