Skip to content

Instantly share code, notes, and snippets.

@jblac
Created February 12, 2013 17:04
Show Gist options
  • Save jblac/4771375 to your computer and use it in GitHub Desktop.
Save jblac/4771375 to your computer and use it in GitHub Desktop.
public $ourDate;
public function _getLastBusinessDay() {
// lets figure out the business days..
$holidayList = array('2013-02-06');
$this->ourDate = date('Y-m-d', strtotime('-5 weekdays'));
foreach ($holidayList as $holiday) {
$timestamp = strtotime($holiday);// holiday lists..
$tmp = strtotime($this->ourDate); // todays date - 5 weekdays
$tmp1 = strtotime(date('Y-m-d')); // todays date
if ($tmp <= $timestamp && $timestamp <= $tmp1 && date("N", $timestamp) != 6 && date("N", $timestamp) != 7) {
$this->ourDate = date('Y-m-d', strtotime('-1 weekday', strtotime($this->ourDate)));
}
}
return $this->ourDate;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment