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
- CakePHP 2
- PHP 5.2
- V 1.x - CakePHP 2
/**
* 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')
);
}
- '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'
{
"require": {
"cakephp-tutorial/autodate": "1.0.0"
}
}
- Download from github https://github.com/cakephp-tutorial/Autodate
- copy in app/Plugin/Autodate
- enable in app/Config/bootstrap.php
CakePlugin::load('Autodate');