You are here

function date_day_of_week in Date 7.2

Same name and namespace in other branches
  1. 5.2 date_api.module \date_day_of_week()
  2. 6.2 date_api.module \date_day_of_week()
  3. 6 date_api.module \date_day_of_week()
  4. 7.3 date_api/date_api.module \date_day_of_week()
  5. 7 date_api/date_api.module \date_day_of_week()

Returns day of week for a given date (0 = Sunday).

Parameters

mixed $date: (optional) A date, default is current local day. Defaults to NULL.

Return value

int The number of the day in the week.

2 calls to date_day_of_week()
DateApiTestCase::testDateApi in date_api/tests/DateApiTestCase.test
Test date_format_date().
date_day_of_week_name in date_api/date_api.module
Returns translated name of the day of week for a given date.

File

date_api/date_api.module, line 2074
This module will make the date API available to other modules.

Code

function date_day_of_week($date = NULL) {
  if (empty($date)) {
    $date = date_now();
  }
  elseif (!is_object($date)) {
    $date = new DateObject($date);
  }
  if (is_object($date)) {
    return $date
      ->format('w');
  }
  return NULL;
}