PHP Classes

PHP Next Working Day: Compute the next working day from today

Recommend this page to a friend!
  Info   View files Example   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 186 This week: 1All time: 8,635 This week: 571Up
Version License PHP version Categories
next-working-day 0.0.1GNU General Publi...5PHP 5, Time and Date
Description 

Author

This class can compute the next working day from today.

It extends the DateTime class and takes a given time of the day, which defaults to now, and computes the next working day.

The class considers a range of working hours, and whether it is Sunday or an holiday to exclude from the list working days.

It can also return the formatted day according to a given format template.

Innovation Award
PHP Programming Innovation award nominee
October 2015
Number 4


Prize: One book of choice by Packt
When a store is closed, sometimes it is useful to inform customers when will be the next time it will be opened, but that depends on the current week day and whether the next day will be a holiday or not.

This class can compute the current or the next working day considering open business hours, Sundays and holidays.

Manuel Lemos
Picture of Ravi Kumar
  Performance   Level  
Name: Ravi Kumar is available for providing paid consulting. Contact Ravi Kumar .
Classes: 6 packages by
Country: India India
Age: 40
All time rank: 1719101 in India India
Week rank: 103 Up8 in India India Up
Innovation award
Innovation award
Nominee: 2x

Example

<?php

include_once 'Response.php';

$o = new Response( null, 'Asia/Calcutta' );

$k = $o->next('2016-01-01 09:02:30');

$response = $k->response;
$reasons = $k->reasons;
$current = $k->current;
$next = $k->next;

echo
'Current Date : ', $current->format('F'), ' ' , $current->format('d'), ' ' , $current->format('l'), ' ' , $current->format('h'), ':' , $current->format('i'), ' ' , $current->format('A'), '<br>' ;
echo
'Response in : ', $response, '<br>' ;

echo
'Reasons for delay : ';
if (
$reasons ) {

    echo
'<ul>';
    foreach (
$reasons as $key => $value) {
       
        if (
is_array($value) ) {
            echo
'<li>';
            echo
$key . ' -> ' . implode(', ', $value);
            echo
'</li>';
        }
        else {
            echo
'<li>';
            echo
$key . ' -> ' . $value;
            echo
'</li>';
        }
    }
    echo
'</ul>';
}


echo
'Response Date : ', $next->format('F'), ' ' , $next->format('d'), ' ' , $next->format('l'), ' ' , $next->format('h'), ':' , $next->format('i'), ' ' , $next->format('A'), '<br>' ;


Details

Response

This class can compute the next working day from today.

It extends the DateTime class and takes a given time of the day, which defaults to now, and computes the next working day.

The class considers a range of working hours, and whether it is Sunday or an holiday to exclude from the list working days.

It can also return the formatted day according to a given format template.

Added holidays reasons.


  Files folder image Files  
File Role Description
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file LICENSE Lic. License
Accessible without login Plain text file README.md Data Auxiliary data
Plain text file Response.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:186
This week:1
All time:8,635
This week:571Up