edatetimebehavior Automatically convert ActiveRecord MySQL date and datetime field to PHP5 DateTime Object

  1. Tested with:
  2. Requirements
  3. Installation
  4. Usage

This behavior can be attached to ActiveRecord model for automatically conversion MySQL date and datetime field to PHP5 DateTime object.

Tested with:

  1. PHP 5.3.13
  2. MySQL 5.5.24
  3. Yii 1.1.10.r3566

Requirements

  1. >= PHP 5.2.0

Installation

Extract the release file and put it under protected/extensions.

In your ActiveRecord model, add the following code:

public function behaviors()
{
    return array('edatetimebehavior' => array('class' => 'ext.EDateTimeBehavior'));
}

You may have to change 'ext.EDateTimeBehavior' if you don't put the file to 'protected/extensions'.

Usage

Nothing much, now your date/datetime attributes can be used as a PHP5 DateTime object.

Enjoy the convenience.

Inspired from i18n-datetime-behavior

This is my first extension, any comments are welcome :)

6 0
9 followers
711 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Date and Time
Developed by: katz
Created on: May 15, 2012
Last updated: 11 years ago

Downloads

show all

Related Extensions