note 92090 added to function.date
| From: | ddd888 at mail333 dot com | Date: | Wed, 08 Jul 2009 10:56:23 +0000 |
| Subject: | note 92090 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-158057@lists.php.net to get a copy of this message | ||
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');
?>
----
Server IP: 78.41.104.4
Probable Submitter: 217.22.163.126
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/92090
Del: integrated -- https://master.php.net/note/delete/92090/integrated
Del: useless -- https://master.php.net/note/delete/92090/useless
Del: bad code -- https://master.php.net/note/delete/92090/bad+code
Del: spam -- https://master.php.net/note/delete/92090/spam
Del: non-english -- https://master.php.net/note/delete/92090/non-english
Del: in docs -- https://master.php.net/note/delete/92090/in+docs
Del: other reasons-- https://master.php.net/note/delete/92090
Reject -- https://master.php.net/note/reject/92090
Search -- https://master.php.net/manage/user-notes.php