Day Of Week
This algorithm finds the current day of week according to the input date.
/**************
Sunday = 0
Monday = 1
Tuesday = 2
Wednesday = 3
Thursday = 4
Friday = 5
Saturday = 6
**************/
function GetDayOfWeek($year, $month, $day) {
$monthTable = array(0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4);
$year -= (($month < 3) ? 1 : 0);
return ($year + $year / 4 - $year / 100 + $year / 400 + $monthTable[$month - 1] + $day) % 7;
}
Example
$value = GetDayOfWeek(2015, 8, 7);
Output
5