PHP Classes

PHP Business Days Calculator: Get the business days after today or a given date

Recommend this page to a friend!
  Info   View files Documentation   View files View files (15)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 62 All time: 10,385 This week: 68Up
Version License PHP version Categories
business-days-calcul 1.0MIT/X Consortium ...5PHP 5, Time and Date
Description 

Author

This class can get the business days after today or a given date.

It can take as parameter a given date that will be taken as a reference.

The class can return one or more dates of the next business days after the given date considering the weekends and the regular holiday dates like Christmas, Easter, Corpus Christi, etc..

Optionally the class can also consider business days of specific countries like Brazil.

Picture of Fernando Val
  Performance   Level  
Name: Fernando Val <contact>
Classes: 5 packages by
Country: Brazil Brazil
Age: 55
All time rank: 2323158 in Brazil Brazil
Week rank: 312 Up26 in Brazil Brazil Up

Documentation

PHP Business Days Calculator

Latest Stable Version Build Status PHP Composer PHPStan Codacy Badge StyleCI Total Downloads License

This class can get the business days after today or a given date.

It can take as parameter a given date that will be taken as a reference.

The class can return one or more dates of the next business days after the given date considering the weekends and the regular holiday dates like Christmas, Easter, Corpus Christi, etc..

Optionally the class can also consider business days of specific countries like Brazil.

Requirements

  • PHP 7.3+

Instalation

To get the latest stable version of this component use:

"require": {
    "springy-framework/business-days-calculator": "*"
}

in your composer.json file.

Usage

I suppose that the following example is all you need:

<?php

require 'vendor/autoload.php'; // If you're using Composer (recommended)

// Using dynamic mode
$today = new DateTime();
$bdCalc = new Springy\BusinessDaysCalculator($today);
$newDate = $bdCalc->addBrazilianHolidays((int) $today->format('Y'))
    ->addBrazilianHolidays((int) $today->format('Y') + 1)
    ->addBusinessDays(20)
    ->getDate();
var_dump($newDate);

if ($bdCalc->isBusinessDay()) {
    echo "Is a business day\n";
}

// Getting nth business date in 'Y-m-d' format string without create an object
echo "The 20th business day from now is "
    . Springy\BusinessDaysCalculator::getBusinessDate(20)
    . "\n";

Contributing

Please read our contributing document and thank you for doing that.

Code of Conduct

In order to ensure that our community is welcoming to all, please review and abide by the code of conduct.

License

This project is licensed under The MIT License (MIT).


  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imagesrc (1 file)
Files folder imagetests (2 files)
Accessible without login Plain text file .remarkrc Data Auxiliary data
Accessible without login Plain text file .styleci.yml Data Auxiliary data
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file codesize.xml Data Auxiliary data
Accessible without login Plain text file CODE_OF_CONDUCT.md Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file CONTRIBUTING.md Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpcs.xml Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file php.yml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
  Plain text file BusinessDaysCalculator.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Accessible without login Plain text file bootstrap.php Aux. Auxiliary script
  Plain text file businessDaysTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:62
This week:0
All time:10,385
This week:68Up
User Comments (1)