Code Monkey home page Code Monkey logo

php-superdate's Introduction

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.

php-superdate's People

Contributors

dependabot[bot] avatar ludovicm67 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.