Back to Date class

Method monthToString

public string
monthToString
(mixed $month, mixed $abbr = false)
Translates month number to a string.
Parameters
  • int $month The numeric month of the year.
  • bool $abbr If true, return the abbreviated month string
Returns
  • string The month of the year.
Since
  • 1.7.0
Class: Date
Project: Joomla

Method monthToString - Source code

/**
 * Translates month number to a string.
 *
 * @param   integer  $month  The numeric month of the year.
 * @param   boolean  $abbr   If true, return the abbreviated month string
 *
 * @return  string  The month of the year.
 *
 * @since   1.7.0
 */
public function monthToString($month, $abbr = false)
{
    switch ($month) {
        case 1:
            return $abbr ? Text::_('JANUARY_SHORT') : Text::_('JANUARY');
        case 2:
            return $abbr ? Text::_('FEBRUARY_SHORT') : Text::_('FEBRUARY');
        case 3:
            return $abbr ? Text::_('MARCH_SHORT') : Text::_('MARCH');
        case 4:
            return $abbr ? Text::_('APRIL_SHORT') : Text::_('APRIL');
        case 5:
            return $abbr ? Text::_('MAY_SHORT') : Text::_('MAY');
        case 6:
            return $abbr ? Text::_('JUNE_SHORT') : Text::_('JUNE');
        case 7:
            return $abbr ? Text::_('JULY_SHORT') : Text::_('JULY');
        case 8:
            return $abbr ? Text::_('AUGUST_SHORT') : Text::_('AUGUST');
        case 9:
            return $abbr ? Text::_('SEPTEMBER_SHORT') : Text::_('SEPTEMBER');
        case 10:
            return $abbr ? Text::_('OCTOBER_SHORT') : Text::_('OCTOBER');
        case 11:
            return $abbr ? Text::_('NOVEMBER_SHORT') : Text::_('NOVEMBER');
        case 12:
            return $abbr ? Text::_('DECEMBER_SHORT') : Text::_('DECEMBER');
    }
}