function date_calc_begin_of_week in Date 6.2
Same name and namespace in other branches
- 5.2 date_php4/date_php4_calc.inc \date_calc_begin_of_week()
- 6 date_php4/date_php4_calc.inc \date_calc_begin_of_week()
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.
Parameters
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.
string $format: The string indicating how to format the output.
Return value
string The date in the desired format.
3 calls to date_calc_begin_of_week()
- date_calc_begin_of_next_week in date_php4/
date_php4_calc.inc - Find the month day of the beginning of week after given date, using variable_get('date_first_day', 1). Can return weekday of next month.
- date_calc_begin_of_prev_week in date_php4/
date_php4_calc.inc - Find the month day of the beginning of week before given date, using variable_get('date_first_day', 1). Can return weekday of prev month.
- date_calc_get_calendar_week in date_php4/
date_php4_calc.inc - Return an array with days in week.
File
- date_php4/
date_php4_calc.inc, line 1075
Code
function date_calc_begin_of_week($day = 0, $month = 0, $year = 0, $format = DATE_CALC_FORMAT) {
if (empty($year)) {
$year = date_calc_get_year();
}
if (empty($month)) {
$month = date_calc_get_month();
}
if (empty($day)) {
$day = date_calc_get_day();
}
$this_weekday = date_dow($day, $month, $year);
$interval = (7 - variable_get('date_first_day', 1) + $this_weekday) % 7;
return date_calc_days_to_date(date_calc_date_to_days($day, $month, $year) - $interval, $format);
}