private function ApStyleDateFormatter::formatMonth in AP Style Date 8
Return month format code based on AP Style rules.
Parameters
\Drupal\Core\Datetime\DrupalDateTime $date: Drupal date object.
Return value
string Date format string.
2 calls to ApStyleDateFormatter::formatMonth()
- ApStyleDateFormatter::formatRange in src/
ApStyleDateFormatter.php - Format a timestamp to an AP style date format.
- ApStyleDateFormatter::formatTimestamp in src/
ApStyleDateFormatter.php - Format a timestamp to an AP style date format.
File
- src/
ApStyleDateFormatter.php, line 53
Class
- ApStyleDateFormatter
- Services for formatting date types using AP Style Date rules.
Namespace
Drupal\date_ap_styleCode
private function formatMonth(DrupalDateTime $date) {
switch ($date
->format('m')) {
case '03':
case '04':
case '05':
case '06':
case '07':
// Short months get the full print out of their name.
$month_format = 'F';
break;
case '09':
// September is abbreviated to 'Sep' by PHP but we want 'Sept'.
$month_format = 'M\\t.';
break;
default:
// Other months get an abbreviated print out followed by a period.
$month_format = 'M.';
break;
}
return $month_format;
}