Skip to content

Instantly share code, notes, and snippets.

@SeanJA
Created March 7, 2011 14:58
Show Gist options
  • Save SeanJA/858593 to your computer and use it in GitHub Desktop.
Save SeanJA/858593 to your computer and use it in GitHub Desktop.
Get the previous business day from a timestamp
<?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