Created
March 7, 2011 14:58
-
-
Save SeanJA/858593 to your computer and use it in GitHub Desktop.
Get the previous business day from a timestamp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function previous_business_day($timestamp, $holidays = array()) { | |
do { | |
$timestamp = $timestamp - 86400; | |
$day_of_week = date('l', $timestamp); | |
$due = date('Y-m-d', $timestamp); | |
} while (in_array($day_of_week, array('Sunday', 'Saturday')) || in_array($due, $holidays)); | |
$checkdate = date('l Y-m-d', $timestamp); | |
return $checkdate; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment