自动转换日期字段

安装: 16

依赖: 0

建议者: 0

安全: 0

星星: 2

关注者: 2

分支: 1

开放问题: 0

类型:cakephp-plugin

1.0.1 2015-12-28 14:01 UTC

This package is not auto-updated.

Last update: 2024-09-28 18:28:16 UTC


README

一个 CakePHP 插件,可以将日期字段从 SQL 格式自动转换为所选日期格式(例如:d/m/Y)。在保存到数据库之前、在查找(以匹配数据库中的条件)之前、在查找之后以及在更新之后自动转换日期。

Total Downloads Latest Stable Version

要求

  • 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'

安装

使用 composer

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

手动安装

CakePlugin::load('Autodate');