For those of who haven't take a lit class in a while, MLA is Modern Language Style and months are abbreviated like this
With PHP, it's easy to get either abbreviated or not
$date = DateTime::createFromFormat('Ymd', $unformatted_date_string);
// abbreviated
echo $date->format('M d, Y');
// not abbreviated
echo $date->format('m d, Y');
But looked through http://php.net/manual/en/datetime.formats.date.php and not seeing a way to get a mix of both. Is there a better solution than string parsing?
You could always just format months which are greater than 4 characters in length. It seems like that's all that you really want to do.
// load array with all months for example
for ($x = 1; $x <= 12; $x++) {
$dates[] = new DateTime('2016-' . $x . '-1');
}
// length is > 4
// if: echo abbreviated month
// else: echo unformatted month
foreach($dates as $date) {
if (strlen($date->format('F')) > 4) {
echo $date->format('M') . ".";
} else {
echo $date->format('F');
}
echo "
";
}
Results: Jan. Feb. Mar. Apr. May June July Aug. Sep. Oct. Nov. Dec.