<?php
// calculates the nearest weekday (e.g. Sunday) to a given date.
// Author John Borda January 2008 www.bordaline.co.uk
// version 1.0.0
// debugging help from Jake Arkinstall www.JakeArkinstall.com
class nearestweekday {
private $day1;
public function nrweekday($day1)
{
$day1 = ($day1 -259200); //subtract 3 days
$checkday = date("l", $day1);
// $checkday1 = $day1;
while($checkday != "Sunday"){ //change this day of week to suit your app.
$day1 = $day1 + 86400;
$checkday = date("l", $day1);
}
$this->day1 = $day1;
return date('Y-m-d',$this->day1);
}
}
?>