function DateHelper::dayOfWeekName
Same name in other branches
- 9 core/lib/Drupal/Core/Datetime/DateHelper.php \Drupal\Core\Datetime\DateHelper::dayOfWeekName()
- 8.9.x core/lib/Drupal/Core/Datetime/DateHelper.php \Drupal\Core\Datetime\DateHelper::dayOfWeekName()
- 11.x core/lib/Drupal/Core/Datetime/DateHelper.php \Drupal\Core\Datetime\DateHelper::dayOfWeekName()
Returns translated name of the day of week for a given date.
Parameters
mixed $date: (optional) A DrupalDateTime object or a date string. Defaults to NULL, which means use the current date.
string $abbr: (optional) Whether to return the abbreviated name for that day. Defaults to TRUE.
Return value
\Drupal\Core\StringTranslation\TranslatableMarkup|null The name of the day in the week for that date, or null if the $date has errors.
1 call to DateHelper::dayOfWeekName()
- DateHelperTest::testDayOfWeekName in core/
tests/ Drupal/ Tests/ Core/ Datetime/ DateHelperTest.php - @covers ::dayOfWeekName
File
-
core/
lib/ Drupal/ Core/ Datetime/ DateHelper.php, line 528
Class
- DateHelper
- Defines Gregorian Calendar date values.
Namespace
Drupal\Core\DatetimeCode
public static function dayOfWeekName($date = NULL, $abbr = TRUE) {
$date = $date ?? 'now';
if (!$date instanceof DrupalDateTime) {
$date = new DrupalDateTime($date);
}
if (!$date->hasErrors()) {
$dow = self::dayOfWeek($date);
$days = $abbr ? self::weekDaysAbbr() : self::weekDays();
return $days[$dow];
}
return NULL;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.