You are here

function date_day_of_week in Date 7

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.2 date_api/date_api.module \date_day_of_week()

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

Parameters

mixed $date: a date, default is current local day

Return value

the number of the day in the week

2 calls to date_day_of_week()
DateAPITestCase::testDateAPI in tests/date_api.test
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 1390
This module will make the date API available to other modules. Designed to provide a light but flexible assortment of functions and constants, with more functionality in additional files that are not loaded unless other modules specifically include them.

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;
}