RE: [PHP] Time Language Settings
| From: | Don Read | Date: | Thu, 21 Jun 2001 18:42:47 +0000 |
| Subject: | RE: [PHP] Time Language Settings | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-54784@lists.php.net to get a copy of this message | ||
On 21-Jun-01 Ray Hilton wrote:
> How do I go arround getting php to output the time() function in a
> different language? I have tried the setlocale() function to no avail,
> perhaps my system doesn't have the appropriate locale to do this? If
> so, then how do install them on Red Hat 7?
check strftime() ?
(You _will_ need the appropriate LOCALE files in ../share/locale )
<?php
function initlocale($loc='en_US.ISO_8859-1') {
if (! setlocale('LC_TIME', $loc)) {
debug(__FILE__, __LINE__, "Unsupported TIME locale $loc");
exit();
}
list($lang, $charset) = explode('.', $loc);
// map Linux charset -> RFC standard
$charset=strtr($charset, '_', '-');
Header("Content-Language: $lang, en");
Header("Content-Type: text/html; charset=$charset");
}
function formattime($tm='') {
$fmtstr='%A, %B %e %l:%M%p %Z';
if (empty($tm))
$tm=mktime();
$ds=date('Y-m-d-h-i', $tm);
list ($y, $m, $d, $h, $n)=explode('-', $ds);
$datestr=strftime($fmtstr, mktime($h, $n, 0, $m, $d, $y)) ;
return($datestr);
}
initlocale('de_DE.DIS_8859-15');
print formattime);
?>
Regards,
--
Don Read dread@texas.net
-- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.