1. Go to this page and download the library: Download andydune/datetime 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/ */
andydune / datetime example snippets
use AndyDuneTest\DateTime\DateTime;
$dt = new DateTime();
$dt->getTimestamp; // == time()
use AndyDuneTest\DateTime\DateTime;
$dt = new DateTime(time() + 3600);
$dt->getTimestamp; // == time() + 3600
use AndyDuneTest\DateTime\DateTime;
$dt = new DateTime('2018-04-11'); // default format is mysql datetime
$dt = new DateTime('11.04.2017', 'd.m.Y'); // own format - use string as for date() function
use AndyDuneTest\DateTime\DateTime;
$dt = new DateTime(new \DateTime());
use AndyDuneTest\DateTime\DateTime;
$dt = new DateTime();
echo $dt->format('Y-m-d'); // 2107-04-12
echo $dt->format('H:i'); // 10:04
use AndyDuneTest\DateTime\DateTime;
$dt = new DateTime();
$dt->add('2D'); // two days
$dt->add('T2S'); // two seconds
$dt->add('6YT5M'); // six years and five minutes
use AndyDuneTest\DateTime\DateTime;
$dt = new DateTime();
$dt->add('+5 weeks'); // 5 weeks to future
$dt->add('12 day'); // 12 days to future
$dt->add('-7 weekdays'); // 7 working daye to past
$dt->add('3 months - 5 days'); // 3 months to future and 5 days to past
use AndyDune\DateTime\Tool\Statistics\BringNumberInDayToNumberInWeek;
$data = json_decode($json, true);
$stat = new BringNumberInDayToNumberInWeek($data);
$weeks = $stat->getWeeksWithCalendarDivision();
use AndyDune\DateTime\Action\IsWorkingDay;
use AndyDune\DateTime\DateTime;
$dt = new DateTime('18-04-2018', 'd-m-Y');
$dt->setAction(new IsWorkingDay())->executeAction(); // true
$dt = new DateTime('22-04-2018', 'd-m-Y');
$dt->setAction(new IsWorkingDay())->executeAction(); // false
use AndyDune\DateTime\Action\PlusWorkingDays;
use AndyDune\DateTime\DateTime;
$dt = new DateTime('28-04-2018', 'd-m-Y');
$action = new PlusWorkingDays();
$action->setNoWorkingDays(['1-05', '30-04']); // set list of official holidays
$action->setWorkingDays(['28-04']); // set list of working sundays or saturdays
$dt->setAction($action)->executeAction(1); // to know working date after 1 day
$dt->format('d-m-Y'); // '02-05-2018'
$action->getDaysPlus(); // 4 days