note 76514 added to function.date
| From: | ThomasEdison at osu1 dot php dot net | Date: | Wed, 18 Jul 2007 22:16:29 +0000 |
| Subject: | note 76514 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128702@lists.php.net to get a copy of this message | ||
This function is like date, but it "speaks" Hungarian (or an other language)
<?php
/*
these are the hungarian 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_hu($formatum, $timestamp=0) {
if (($timestamp <= -1) || !is_numeric($timestamp)) return '';
$q['ö'] = array(-1 => 'w', 'vasárnap',
'hétfÅ', 'kedd', 'szerda', 'csütörtök',
'péntek', 'szombat');
$q['Ã'] = array(-1 => 'w', 'Vasárnap',
'HétfÅ', 'Kedd', 'Szerda', 'Csütörtök',
'Péntek', 'Szombat');
$q['Å'] = array(-1 => 'w', 'va', 'hé',
'ke', 'sze', 'csü', 'pé', 'szo');
$q['Å'] = array(-1 => 'w', 'Va', 'Hé',
'Ke', 'Sze', 'Csü', 'Pé', 'Szo');
$q['ü'] = array(-1 => 'n', '', 'január',
'február', 'március', 'április', 'május',
'június', 'július', 'augusztus', 'szeptember',
'október', 'november', 'december');
$q['Ã'] = array(-1 => 'n', '', 'Január',
'Február', 'Március', 'Ãprilis', 'Május',
'Június', 'Július', 'Augusztus', 'Szeptember',
'Október', 'November', 'December');
$q['ű'] = array(-1 => 'n', '', 'jan',
'febr', 'márc', 'ápr', 'máj', 'júni',
'júli', 'aug', 'szept', 'okt', 'nov',
'dec');
$q['Ű'] = array(-1 => 'n', '', 'Jan',
'Febr', 'Márc', 'Ãpr', 'Máj', 'Júni',
'Júli', 'Aug', 'Szept', 'Okt', 'Nov',
'Dec');
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_hu('Y. ü j. (ö) G:i');
?>
----
Server IP: 195.70.37.52
Probable Submitter: 84.2.209.123
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/76514
Del: integrated -- https://master.php.net/note/delete/76514/integrated
Del: useless -- https://master.php.net/note/delete/76514/useless
Del: bad code -- https://master.php.net/note/delete/76514/bad+code
Del: spam -- https://master.php.net/note/delete/76514/spam
Del: non-english -- https://master.php.net/note/delete/76514/non-english
Del: in docs -- https://master.php.net/note/delete/76514/in+docs
Del: other reasons-- https://master.php.net/note/delete/76514
Reject -- https://master.php.net/note/reject/76514
Search -- https://master.php.net/manage/user-notes.php