You are here

public static function PersianDateHelper::dayOfWeek in Persian Date for Drupal 8 8.4

Same name and namespace in other branches
  1. 8 src/PersianDateHelper.php \Drupal\persian_date\PersianDateHelper::dayOfWeek()

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

Parameters

mixed $date: (optional) A DrupalDateTime object or a date string. Defaults to NULL, which means use the current date.

Return value

int The number of the day in the week.

Overrides DateHelper::dayOfWeek

1 call to PersianDateHelper::dayOfWeek()
PersianDateHelper::dayOfWeekName in src/PersianDateHelper.php
Returns translated name of the day of week for a given date.

File

src/PersianDateHelper.php, line 485

Class

PersianDateHelper

Namespace

Drupal\persian_date

Code

public static function dayOfWeek($date = NULL) {
  if (!$date instanceof DrupalDateTime) {
    $date = new DrupalDateTime($date);
  }
  if (!$date
    ->hasErrors()) {
    return $date
      ->format('w');
  }
  return NULL;
}