Some useful functions for working with dates
Just run the following command: composer require ludovicm67/superdate
to add it to your PHP project!
If you installed using composer, you can now create a file with the following code:
<?php
// import here the composer autoloader
require('./vendor/autoload.php');
// use the namespace for this library
use ludovicm67\SuperDate\Date;
// your code below...
Many ways to initialize the object.
For example:
// value: today
$date = new Date();
$date = new Date(null);
// value: specified date
$date = new Date("2019-03-21");
Get an array of all days from the current date to an other one.
Example:
$date = new Date("2019-03-21");
$allDaysTo = $date->allDaysTo("2019-04-03");
// $allDaysTo will be an array containing all 14 days
// between 2019-03-21 and 2019-04-03 included
$date->isWeekDay(); // true if between monday and friday, false if saturday or sunday
$date->isWeekEnd(); // false if between monday and friday, true if saturday or sunday
Based on Alsace, France holidays.
Usage:
$date->isHoliday(); // true if holiday, false if not
Feel free to fork, commit and open a pull-request.
Or just open an issue here: https://github.com/ludovicm67/php-superdate/issues.