Created
February 10, 2019 09:01
-
-
Save AlekVolsk/c4b9e03d6683a77a4ffb4a7a239e14a3 to your computer and use it in GitHub Desktop.
Кастомная дата для джумлы, месяц прописью
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Joomla\CMS\Language\Text; | |
use Joomla\CMS\HTML\HTMLHelper; | |
function getDateAlt($date, $format) | |
{ | |
$months = array( | |
Text::_('JANUARY') => 'Январь', | |
Text::_('FEBRUARY') => 'Февраль', | |
Text::_('MARCH') => 'Март', | |
Text::_('APRIL') => 'Апрель', | |
Text::_('MAY') => 'Май', | |
Text::_('JUNE') => 'Июнь', | |
Text::_('JULY') => 'Июль', | |
Text::_('AUGUST') => 'Август', | |
Text::_('SEPTEMBER') => 'Сентябрь', | |
Text::_('OCTOBER') => 'Октябрь', | |
Text::_('NOVEMBER') => 'Ноябрь', | |
Text::_('DECEMBER') => 'Декабрь', | |
); | |
$monthsD = array( | |
Text::_('JANUARY') => 'января', | |
Text::_('FEBRUARY') => 'февраля', | |
Text::_('MARCH') => 'марта', | |
Text::_('APRIL') => 'апреля', | |
Text::_('MAY') => 'мая', | |
Text::_('JUNE') => 'июня', | |
Text::_('JULY') => 'июля', | |
Text::_('AUGUST') => 'августа', | |
Text::_('SEPTEMBER') => 'сентября', | |
Text::_('OCTOBER') => 'октября', | |
Text::_('NOVEMBER') => 'ноября', | |
Text::_('DECEMBER') => 'декабря', | |
); | |
$result = HTMLHelper::_('date', $date, $format); | |
if (strpos($format, 'd') === false && strpos($format, 'F') !== false) { | |
foreach ($months as $key => $m) { | |
if (strpos($result, $key) !== false) { | |
$result = str_replace($key, $m, $result); | |
} | |
} | |
} | |
if (strpos($format, 'd') !== false && strpos($format, 'F') !== false) { | |
foreach ($monthsD as $key => $m) { | |
if (strpos($result, $key) !== false) { | |
$result = str_replace($key, $m, $result); | |
} | |
} | |
} | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment