PHPackages                             terranc/yii2-datetime-compare - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. terranc/yii2-datetime-compare

ActiveYii2-extension[Validation &amp; Sanitization](/categories/validation)

terranc/yii2-datetime-compare
=============================

DateTime comparison validator

2.3(1y ago)017BSD-3-ClausePHP

Since Mar 18Pushed 1y agoCompare

[ Source](https://github.com/terranc/yii2-datetime-compare)[ Packagist](https://packagist.org/packages/terranc/yii2-datetime-compare)[ Docs](https://github.com/terranc/yii2-datetime-compare)[ RSS](/packages/terranc-yii2-datetime-compare/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

yii2-datetime-compare
=====================

[](#yii2-datetime-compare)

[![Latest Stable Version](https://camo.githubusercontent.com/a67ce652816e9c37af0cef6ecae5aa23d6665a7ef038ce2686fb2bbe2f8d7a48/68747470733a2f2f706f7365722e707567782e6f72672f656d70617468792f796969322d6461746574696d652d636f6d706172652f762f737461626c652e737667)](https://packagist.org/packages/empathy/yii2-datetime-compare)[![Latest Unstable Version](https://camo.githubusercontent.com/6c97e85ee61c473639a2aa86eccc82e5326f5c293ece6bb4b3c625f7e484733b/68747470733a2f2f706f7365722e707567782e6f72672f656d70617468792f796969322d6461746574696d652d636f6d706172652f762f756e737461626c652e737667)](https://packagist.org/packages/empathy/yii2-datetime-compare)[![License](https://camo.githubusercontent.com/4d825a522a05e78baa4f81ed78f7e1bd6be7ad4c961919ec23323120b517c8c4/68747470733a2f2f706f7365722e707567782e6f72672f656d70617468792f796969322d6461746574696d652d636f6d706172652f6c6963656e73652e737667)](https://packagist.org/packages/empathy/yii2-datetime-compare)[![Total Downloads](https://camo.githubusercontent.com/3004346435ab66c92a80d36fe96f6a913e0c563a61123cb3a35ef0967e7280b5/68747470733a2f2f706f7365722e707567782e6f72672f656d70617468792f796969322d6461746574696d652d636f6d706172652f646f776e6c6f6164732e737667)](https://packagist.org/packages/empathy/yii2-datetime-compare)[![Monthly Downloads](https://camo.githubusercontent.com/bcd182b13e03eabbfa066cef2eee0fb4f22e80d6a37af21d0892ff3712f0ac1a/68747470733a2f2f706f7365722e707567782e6f72672f656d70617468792f796969322d6461746574696d652d636f6d706172652f642f6d6f6e74686c792e706e67)](https://packagist.org/packages/empathy/yii2-datetime-compare)[![Daily Downloads](https://camo.githubusercontent.com/865cdb4dde680069483066d3de4e8ed220e6350a27a38f8eb35ad3c1a2e12478/68747470733a2f2f706f7365722e707567782e6f72672f656d70617468792f796969322d6461746574696d652d636f6d706172652f642f6461696c792e706e67)](https://packagist.org/packages/empathy/yii2-datetime-compare)

DateTime comparison validator for Yii Framework 2.0. Temporary solution until this [enhancement](https://github.com/yiisoft/yii2/issues/3581) is implemented.

\[\[Empathy\\Validators\\DateTimeCompareValidator|compare\]\]
--------------------------------------------------------------

[](#empathyvalidatorsdatetimecomparevalidatorcompare-)

```
[
    // validates if the value of "birthday" attribute equals to that of "birthday_repeat"
    ['birthday', DateTimeCompareValidator::className()],

    // validates if birthday is less than or equal to today
    ['birthday', DateTimeCompareValidator::className(), 'compareValue' => date('Y-m-d H:i:s'), 'operator' => ' 'driver_license_expiry', 'operator' => '
