oppara/cakephp-plugin-unix-timestamp

UnixTimestamp behavior

0.1.0 2018-03-12 16:35 UTC

This package is not auto-updated.

Last update: 2024-05-12 03:14:16 UTC


README

Build Status codecov

You can use this UnixTimestampBehavior insted of CakePHP's TimestampBehavior when want to save the unix timestamp

Installation

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

composer require oppara/cakephp-plugin-unix-timestamp

Enable plugin

You need to enable the plugin your config/bootstrap.php file:

<?php
Plugin::load('Oppara/UnixTimestamp');

If you are already using Plugin::loadAll();, then this is not necessary.

Usage

more info https://book.cakephp.org/3.0/en/orm/behaviors/timestamp.html

CREATE TABLE users (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(255) NOT NULL,
    password VARCHAR(255) NOT NULL,
    created INT,
    modified INT
);
<?php
namespace App\Model\Table;

use Cake\ORM\Table;

class UsersTable extends Table
{
    public function initialize(array $config)
    {
        $this->addBehavior('Oppara/UnixTimestamp.UnixTimestamp');
    }
}