1. Go to this page and download the library: Download cerbero/date library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cerbero / date example snippets
'aliases' => array(
'Date' => 'Cerbero\Date',
)
use Cerbero\Date;
// pass any English textual date to get an instance of DateTime
$DateTime = Date::create('10 May 2000');
// you can pass an array as argument to create an array of DateTime objects
$array = Date::create(array('now', 'next Thursday'));
// or even unlimited arguments, an array is returned as well
$array = Date::create('2 March 2010', 'now', 'last Tuesday');
$true = Date::isValid('5 October 1980');
// 13 is recognized as month in English dates, so it's not valid
$false = Date::isValid('13/01/2005');
// '1999-01-30'
$string = Date::format('30 January 1999', 'Y-m-d');
// '1st April, 2014'
$string = Date::format(new DateTime('2014-04-01'), 'jS F, Y');
// array('12/11/10', '01/04/14')
$array = Date::format(array('Nov-12-10', new DateTime('2014-04-01')), 'd/m/y');
// check if the first date is Less Than the second one
$false = Date::lt('2007 June', new DateTime('2007-06-01'));
// check if the first date is Less Than or Equals the second one
$true = Date::lte(new DateTime('2007-06-01'), '2007 June');
// check if the first date EQuals the second one
$true = Date::eq('2007 June', new DateTime('2007-06-01'));
// check if the first date does Not EQual the second one
$false = Date::neq(new DateTime('2007-06-01'), '2007 June');
// check if the first date is Greater Than or Equals the second one
$true = Date::gte('2007 June', new DateTime('2007-06-01'));
// check if the first date is Greater Than the second one
$false = Date::gt(new DateTime('2007-06-01'), '2007 June');
// '03/10/1998'
$string = Date::earliest(array('03/10/1998', new DateTime('2006-12-09'), 'yesterday'));
// the DateTime with the date '2009-03-06'
$DateTime = Date::earliest('next Wednesday', new DateTime('2009-03-06'), '19 Nov 2010');
// 'tomorrow'
$string = Date::latest('tomorrow', '10 January 2015', new DateTime('2014-11-04'));
// the DateTime with the date '2016-01-01'
$DateTime = Date::latest(array('last Friday', new DateTime('2016-01-01'), '10/06/80'));
// array('Apr-17-1790', 'June 2008', new DateTime('2015-02-01'))
$array = Date::sort('June 2008', new DateTime('2015-02-01'), 'Apr-17-1790');
// array(new DateTime('2014-11-22'), 'yesterday', 'next Wednesday')
$array = Date::sort(array('next Wednesday', new DateTime('2014-11-22'), 'yesterday'));
// array(new DateTime('2015-02-01'), 'June 2008', 'Apr-17-1790')
$array = Date::reverse('June 2008', new DateTime('2015-02-01'), 'Apr-17-1790');
// array('next Wednesday', 'yesterday', new DateTime('2014-11-22'))
$array = Date::reverse(array('next Wednesday', new DateTime('2014-11-22'), 'yesterday'));
// array of 22 DateTime instances, from 2008-06-10 to 2008-07-01 8'));
// array of 11 DateTime instances, only even dates from 2008-06-10 to 2008-06-30 8'), 2);