note 106196 added to function.date
| From: | dev5er6 at gmail dot com | Date: | Tue, 18 Oct 2011 09:23:10 +0000 |
| Subject: | note 106196 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183951@lists.php.net to get a copy of this message | ||
date_lang[_ini] â Format a local time/date
Description
string date_lang[_ini] ( string $format [, int $timestamp = time() [, int $mode [, string
$language = 'rus']]] )
Parameters
format - date format
timestamp - The optional timestamp parameter is an integer Unix timestamp
mode - Performs case folding. It can be one of MB_CASE_UPPER = 0 , MB_CASE_LOWER = 1, or
MB_CASE_TITLE = 2.
language - key in $a array
Return Values
Returns a formatted date string.
<?php /* DATE_LANG in UTF-8 encoding */
function date_lang($f='', $t=false, $m=null, $l='rus'){
$d='';
$i='UTF-8';
$t=($t&&$t>0&&is_numeric($t))?$t:time();
$c='charset';
$a=array('rus'=>array($c=>/**{add space after
'*'}->*/'windows-1251',//**/'cp-1251',/**/
'Ð'=>array('A','AM'=>'ÐÐ','PM'=>'ÐÐ'),
'а'=>array('a','am'=>'дп','am'=>'пп'),
'Ð'=>array('N','ÐÑ','Ðн','ÐÑ','СÑ','ЧÑ','ÐÑ','Сб'),
'д'=>array('D','Sun'=>'ÐÑ',
'Mon'=>'Ðн', 'Tue'=>'ÐÑ',
'Wed'=>'СÑ', 'Thu'=>'ЧÑ',
'Fri'=>'ÐÑ', 'Sat'=>'Сб'),
'Ð'=>array('l',
'Sunday'
=>'ÐоÑкÑеÑенÑе','Monday'
=>'ÐонеделÑник',
'Tuesday' =>'ÐÑоÑник'
,'Wednesday'=>'СÑеда',
'Thursday'=>'ЧеÑвеÑг' ,'Friday'
=>'ÐÑÑниÑа',
'Saturday'=>'СÑббоÑа'
),
'Ф'=>array('F',
'January'=>'ЯнваÑÑ'
,'February'=>'ФевÑалÑ','March'
=>'ÐаÑÑ',
'April' =>'ÐпÑелÑ' ,'May'
=>'Ðай' ,'June' =>'ÐÑнÑ',
'July' =>'ÐÑлÑ' ,'August'
=>'ÐвгÑÑÑ'
,'September'=>'СенÑÑбÑÑ',
'October'=>'ÐкÑÑбÑÑ','November'=>'ÐоÑбÑÑ'
,'December' =>'ÐекабÑÑ'
),
'Ñ'=>array('F',
'January'=>'ЯнваÑÑ'
,'February'=>'ФевÑалÑ','March'
=>'ÐаÑÑа',
'April' =>'ÐпÑелÑ' ,'May'
=>'ÐаÑ' ,'June' =>'ÐÑнÑ',
'July' =>'ÐÑлÑ' ,'August'
=>'ÐвгÑÑÑа','September'=>'СенÑÑбÑÑ',
'October'=>'ÐкÑÑбÑÑ','November'=>'ÐоÑбÑÑ'
,'December' =>'ÐекабÑÑ'
),
));
$a=isset($a[$l])?$a[$l]:array();
$c=isset($a[$c])?$a[$c]:$c;
if(!count($a))return;
array_shift($a);
foreach(str_split(iconv($i,$c,$f))as$v)
$d.=(!isset($a[$k=iconv($c,$i,$v)]))
?date($k)
:$a[$k][date($a[$k][0])];
if(!is_null($m))$d=mb_convert_case($d,$m,$i);
return $d;
}
?>
$a['rus']['Ð'] and $a['rus']['д'] return value is
identical, but
date('N') - numeric representation of the day of the week 1-7
date('D') - A textual representation of a day, three letters
so $a['rus']['Ð'] auto indexed array and
$a['rus']['д'] is associative array
----
Server IP: 93.93.89.7
Probable Submitter: 217.119.19.86
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/106196
Del: integrated -- https://master.php.net/note/delete/106196/integrated
Del: useless -- https://master.php.net/note/delete/106196/useless
Del: bad code -- https://master.php.net/note/delete/106196/bad+code
Del: spam -- https://master.php.net/note/delete/106196/spam
Del: non-english -- https://master.php.net/note/delete/106196/non-english
Del: in docs -- https://master.php.net/note/delete/106196/in+docs
Del: other reasons-- https://master.php.net/note/delete/106196
Reject -- https://master.php.net/note/reject/106196
Search -- https://master.php.net/manage/user-notes.php