A basic DateRange class
git submodule add https://github.com/zeroasterisk/CakePHP-DateRange.git app/Plugin/DateRange
or
git clone https://github.com/zeroasterisk/CakePHP-DateRange.git app/Plugin/DateRange
add app/Config/bootstrap.php
CakePlugin::load('DateRange', array('bootstrap' => false));
App::uses('DateRange', 'DateRange.Lib');
DateRange::in('2014-01-01', '2014-01-31')->contains('2014-01-01')
DateRange::in('2014-01-01', '2014-01-31')
->setTimezone('America/New_York')
->setTimezone('America/New_York')
->adjustTimes('litle')
->contains('2014-01-01') === TRUE
DateRange::in()
->setTimezone('America/New_York')
->setStart('2014-01-01')
->setEnd('2014-01-31')
->adjustTimes('litle')
->contains('2013-12-31')
$DateRangeObject = new DateRange('2015-01-01', '2015-12-31');
$DateRangeObject->contains('2014-12-31') === FALSE
$DateRangeObject->contains('2015-01-01') === TRUE
$DateRangeObject->contains('2015-01-01', false) === TRUE (not inclusive)
$DateRangeObject->contains('now') ?
build a Behavior to go with this Lib. The Lib does the lifting the Behavior does the coordination / ease-of-use.
- Behavior to setup named ranges with a
start
andstop
field - Behavior to make conditions
dateInRange('now')
- Behavior to check a record
The original version of the Lib is from: https://github.com/imsamurai/CakePHP-DateRange-Utility compliments.