Automatically convert date fields

1.0.1 2015-12-28 14:01 UTC

This package is not auto-updated.

Last update: 2024-11-09 19:04:35 UTC


README

A CakePHP Plugin that will auto convert date fields from SQL format to a chosen date format (eg: d/m/Y). Will auto convert the date before saving to database, before find (to match conditions on db), after find and after update

Total Downloads Latest Stable Version

Requirements

  • CakePHP 2
  • PHP 5.2

Compatibility

  • V 1.x - CakePHP 2

Usage

/**
 * Attach to AppModel to auto convert all date fields
 * or attach it to a single model
 **/
class AppModel extends Model {
    public $actsAs = array(
        'Autodate.Autodate' => array('dateformat' => 'd/m/Y')
    );
}

Available date Formats

  • 'd-m-Y'
  • 'd/m/Y'
  • 'Y/m/d'
  • 'Y-m-d'
  • 'Y-d-m'
  • 'Y/d/m'
  • 'm-d-Y'
  • 'm/d/Y'
  • 'Ymd'
  • 'Ydm'

Installation

Using composer

{
    "require": {
        "cakephp-tutorial/autodate": "1.0.0"
    }
}

Manually Installation

CakePlugin::load('Autodate');