PHPackages                             horat1us/yii2-carbon-behavior - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. horat1us/yii2-carbon-behavior

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

horat1us/yii2-carbon-behavior
=============================

Yii2 Carbon Timestamps Behavior

1.3.0(1y ago)12.0k[1 issues](https://github.com/Horat1us/yii2-carbon-behavior/issues)2MITPHPPHP ^8.1

Since Mar 19Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Horat1us/yii2-carbon-behavior)[ Packagist](https://packagist.org/packages/horat1us/yii2-carbon-behavior)[ RSS](/packages/horat1us-yii2-carbon-behavior/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (3)Dependencies (5)Versions (9)Used By (2)

Yii2 Carbon Behavior
====================

[](#yii2-carbon-behavior)

[![Test & Lint](https://github.com/Horat1us/yii2-carbon-behavior/actions/workflows/php.yml/badge.svg)](https://github.com/Horat1us/yii2-carbon-behavior/actions/workflows/php.yml)[![codecov](https://camo.githubusercontent.com/3a999a0fd6579e712cc1b053cda427ecc01f4b1f8d87ee5f25c8dbac67f7aea6/68747470733a2f2f636f6465636f762e696f2f67682f486f7261743175732f796969322d636172626f6e2d6265686176696f722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/Horat1us/yii2-carbon-behavior)

Behavior to generate timestamps (created\_at, updated\_at etc.) using [Carbon instance](https://github.com/briannesbitt/Carbon).

Main purpose of using Carbon (instead of native `time()` function, implemented in `\yii\behaviors\TimestampBehavior`) is ability to mock this values without tricks (using `Carbon::setTestNow()`).

Used in real projects with MySQL and PostgreSQL.

Installation
------------

[](#installation)

Using [packagist.org](https://packagist.org/packages/horat1us/yii2-carbon-behavior):

```
composer require horat1us/yii2-carbon-behavior:^1.3
```

Usage
-----

[](#usage)

To generate timestamps using Carbon

```
