Good day to all.

There are 3 variables in the page: $ dd, $ mm, $ YYYY, which are already equal to the day, month, year. I wanted to make a date in words with variable values. I didn’t find anything short on the internet, or rather I didn’t find anything there at all. In principle, you can write a code with pens, but if you list the numbers of the day and year in order, it will be very long.

Can anyone have a solution for displaying the date in words? Please share.

  • As an option, it can get away: register all the numbers with sklanenii separately and, according to the rules to display. - Palladium Inhibitor

3 answers 3

Google has it all. Here is an example for a month.

function russian_date(){ $date=explode(".", date("dmY")); switch ($date[1]){ case 1: $m='января'; break; case 2: $m='февраля'; break; case 3: $m='марта'; break; case 4: $m='апреля'; break; case 5: $m='мая'; break; case 6: $m='июня'; break; case 7: $m='июля'; break; case 8: $m='августа'; break; case 9: $m='сентября'; break; case 10: $m='октября'; break; case 11: $m='ноября'; break; case 12: $m='декабря'; break; } echo $date[0].' '.$m.' '.$date[2]; } russian_date(); 

another option

 <?php // Установливаем русскую локаль // или setlocale(LC_ALL, 'ru_RU'); в PHP 4 setlocale(LC_ALL, 'rus_RUS'); // Получаем сегодняшнюю дату // Формируем вывод // %a - короткая запись дня недели (Чт) // %A - обычная запись дня недели (Четверг) // %Y - год полностью (2008) // %y - год кратко (08) // Короче, смотрите маны $data = strftime("%a, %d/%m/%Y", time()); // В PHP4 потребуется конвертация // $data = iconv('ISO-8859-5','windows-1251', $data); echo $data; // В PHP 4 название дня недели // будет начинаться с заглавной буквы // в обычной форме записи ?> 
     function date_rus($d, $m, $y) { $months = array('нулября', 'января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря'); return $d . ' ' . $months[$m] . ' ' . $y . ' года'; } 

      Here's an article on working with dates in MySql. There at the end there is just how to get a date, and without any problems. http://myshinobi.ru/rabota-s-datami-v-mysql/