function DateHelper::daysInMonth
Same name in other branches
- 9 core/lib/Drupal/Core/Datetime/DateHelper.php \Drupal\Core\Datetime\DateHelper::daysInMonth()
- 10 core/lib/Drupal/Core/Datetime/DateHelper.php \Drupal\Core\Datetime\DateHelper::daysInMonth()
- 11.x core/lib/Drupal/Core/Datetime/DateHelper.php \Drupal\Core\Datetime\DateHelper::daysInMonth()
Identifies the number of days in a month for a date.
Parameters
mixed $date: (optional) A DrupalDateTime object or a date string. Defaults to NULL, which means to use the current date.
Return value
int The number of days in the month.
File
-
core/
lib/ Drupal/ Core/ Datetime/ DateHelper.php, line 455
Class
- DateHelper
- Defines Gregorian Calendar date values.
Namespace
Drupal\Core\DatetimeCode
public static function daysInMonth($date = NULL) {
if (!$date instanceof DrupalDateTime) {
$date = new DrupalDateTime($date);
}
if (!$date->hasErrors()) {
return $date->format('t');
}
return NULL;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.