function date_calc_next_day_of_week in Date 6.2
Same name and namespace in other branches
- 5.2 date_php4/date_php4_calc.inc \date_calc_next_day_of_week()
- 6 date_php4/date_php4_calc.inc \date_calc_next_day_of_week()
Returns date of the next specific day of the week from the given date.
Parameters
int $dow: The day of the week (0 = Sunday).
int $day: The day of the month.
int $month: The month.
int $year: The 4 digit year. Do not add leading 0's for years prior to 1000.
bool $on_or_after: If true and days are same, returns current day.
string $format: The string indicating how to format the output.
Return value
string the date in the desired format
1 string reference to 'date_calc_next_day_of_week'
- date_php4.inc in date_php4/
date_php4.inc
File
- date_php4/
date_php4_calc.inc, line 1032
Code
function date_calc_next_day_of_week($dow, $day = 0, $month = 0, $year = 0, $format = DATE_CALC_FORMAT, $on_or_after = FALSE) {
if (empty($year)) {
$year = date_calc_get_year();
}
if (empty($month)) {
$month = date_calc_get_month();
}
if (empty($day)) {
$day = date_calc_get_day();
}
$days = date_calc_date_to_days($day, $month, $year);
$curr_weekday = date_dow($day, $month, $year);
if ($curr_weekday == $dow) {
if (!$on_or_after) {
$days += 7;
}
}
elseif ($curr_weekday > $dow) {
$days += 7 - ($curr_weekday - $dow);
}
else {
$days += $dow - $curr_weekday;
}
return date_calc_days_to_date($days, $format);
}