function date_dow in Date 6
Same name and namespace in other branches
- 5.2 date_php4/date_php4.inc \date_dow()
- 6.2 date_php4/date_php4.inc \date_dow()
Returns day of week for given date (0 = Sunday), works on dates outside normal date range.
Adapted from a function in the ADODB date library by John Lim, more info in date_php4_lib.inc.
Parameters
int $day:
int $month:
int $year:
Return value
the number of the day in the week
15 calls to date_dow()
- DatePHP4LibTest::testPHP4DateLibrary in tests/
date_test.test - date_calc_begin_of_week in date_php4/
date_php4_calc.inc - Find the month day of the beginning of week for given date, using variable_get('date_first_day', 1). Can return weekday of prev month.
- date_calc_end_of_week in date_php4/
date_php4_calc.inc - Find the month day of the end of week for given date, using variable_get('date_first_day', 1). Can return weekday of following month.
- date_calc_first_of_month_weekday in date_php4/
date_php4_calc.inc - Find the day of the week for the first of the month of given date
- date_calc_format in date_php4/
date_php4_calc.inc - Formats the date in the given format, much like strfmt()
File
- date_php4/
date_php4.inc, line 979
Code
function date_dow($day, $month, $year) {
// Gregorian correction from ADODB
if ($year <= 1582) {
if ($year < 1582 || $year == 1582 && ($month < 10 || $month == 10 && $day < 15)) {
$greg_correction = 3;
}
else {
$greg_correction = 0;
}
}
else {
$greg_correction = 0;
}
if ($month > 2) {
$month -= 2;
}
else {
$month += 10;
$year--;
}
$day = floor((13 * $month - 1) / 5) + $day + $year % 100 + floor($year % 100 / 4) + floor($year / 100 / 4) - 2 * floor($year / 100) + 77 + $greg_correction;
$weekday_number = $day - 7 * floor($day / 7);
return $weekday_number;
}