Skip to content

Latest commit

 

History

History
81 lines (52 loc) · 2.01 KB

README.md

File metadata and controls

81 lines (52 loc) · 2.01 KB

Superdate

Some useful functions for working with dates

Latest Stable Version Total Downloads Coverage Status License

Installation

Just run the following command: composer require ludovicm67/superdate to add it to your PHP project!

Getting started

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...

Create a Date object

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");

All days from one date to an other date

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

Is it a week day or a weekend day?

$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

Is it a holiday day?

Based on Alsace, France holidays.

Usage:

$date->isHoliday(); // true if holiday, false if not

Want to contribute?

Feel free to fork, commit and open a pull-request.

Or just open an issue here: https://github.com/ludovicm67/php-superdate/issues.