note 76514 added to function.date

From: 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

« previous php.notes (#128702) next »