note 92090 deleted from function.date by tularis
| From: | tularis@php.net | Date: | Thu, 09 Feb 2012 20:57:00 +0000 |
| Subject: | note 92090 deleted from function.date by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-185987@lists.php.net to get a copy of this message | ||
Note Submitter: ddd888 at mail333 dot com
----
Slightly modified earlier written function for formatting date in russian.
<?php
/*
these are the russian additional format characters
д: full textual representation of the day of the week
Ð: full textual representation of the day of the week (first character is uppercase),
к: short textual representation of the day of the week,
Ð: short textual representation of the day of the week (first character is uppercase),
м: full textual representation of a month
Ð: full textual representation of a month (first character is uppercase),
л: short textual representation of a month
Ð: short textual representation of a month (first character is uppercase),
*/
function date_ru($formatum, $timestamp=0) {
if (($timestamp <= -1) || !is_numeric($timestamp)) return '';
$q['д'] = array(-1 => 'w',
'воÑкÑеÑенÑе','понеделÑник',
'вÑоÑник', 'ÑÑеда',
'ÑеÑвеÑг', 'пÑÑниÑа',
'ÑÑббоÑа');
$q['Ð'] = array(-1 => 'w',
'ÐоÑкÑеÑенÑе','ÐонеделÑник',
'ÐÑоÑник', 'СÑеда',
'ЧеÑвеÑг', 'ÐÑÑниÑа',
'СÑббоÑа');
$q['к'] = array(-1 => 'w', 'вÑ','пн',
'вÑ', 'ÑÑ', 'ÑÑ', 'пÑ',
'Ñб');
$q['Ð'] = array(-1 => 'w', 'ÐÑ','Ðн',
'ÐÑ', 'СÑ', 'ЧÑ', 'ÐÑ',
'Сб');
$q['м'] = array(-1 => 'n', '',
'ÑнваÑÑ', 'ÑевÑалÑ',
'маÑÑа', 'апÑелÑ', 'маÑ',
'иÑнÑ', 'иÑлÑ',
'авгÑÑÑа', 'ÑенÑÑбÑÑ',
'окÑÑбÑÑ', 'ноÑбÑÑ',
'декабÑÑ');
$q['Ð'] = array(-1 => 'n', '',
'ЯнваÑÑ', 'ФевÑалÑ',
'ÐаÑÑ', 'ÐпÑелÑ', 'Ðай',
'ÐÑнÑ', 'ÐÑлÑ', 'ÐвгÑÑÑ',
'СенÑÑбÑÑ', 'ÐкÑÑбÑÑ',
'ÐоÑбÑÑ', 'ÐекабÑÑ');
$q['л'] = array(-1 => 'n', '', 'Ñнв',
'Ñев', 'маÑ', 'апÑ',
'май', 'иÑн', 'иÑл',
'авг', 'Ñен', 'окÑ',
'ноÑ', 'дек');
$q['Ð'] = array(-1 => 'n', '', 'Янв',
'Фев', 'ÐаÑ', 'ÐпÑ',
'Ðай', 'ÐÑн', 'ÐÑл',
'Ðвг', 'Сен', 'ÐкÑ',
'ÐоÑ', 'Ðек');
if ($timestamp == 0)
$timestamp = time();
$temp = '';
$i = 0;
while ( (strpos($formatum, 'д', $i) !== FALSE) || (strpos($formatum,
'Ð', $i) !== FALSE) ||
(strpos($formatum, 'к', $i) !== FALSE) || (strpos($formatum,
'Ð', $i) !== FALSE) ||
(strpos($formatum, 'м', $i) !== FALSE) || (strpos($formatum,
'Ð', $i) !== FALSE) ||
(strpos($formatum, 'л', $i) !== FALSE) || (strpos($formatum,
'Ð', $i) !== FALSE)) {
$ch['д']=strpos($formatum, 'д', $i);
$ch['Ð']=strpos($formatum, 'Ð', $i);
$ch['к']=strpos($formatum, 'к', $i);
$ch['Ð']=strpos($formatum, 'Ð', $i);
$ch['м']=strpos($formatum, 'м', $i);
$ch['Ð']=strpos($formatum, 'Ð', $i);
$ch['л']=strpos($formatum, 'л', $i);
$ch['Ð']=strpos($formatum, 'Ð', $i);
foreach ($ch as $k=>$v)
if ($v === FALSE)
unset($ch[$k]);
$a = min($ch);
$temp .= date(substr($formatum, $i, $a-$i), $timestamp) .
$q[$formatum[$a]][date($q[$formatum[$a]][-1], $timestamp)];
$i = $a+1;
}
$temp .= date(substr($formatum, $i), $timestamp);
return $temp;
}
echo 'Ð¡ÐµÐ³Ð¾Ð´Ð½Ñ '.date_ru('Ð, d л Y');
?>