Re: date() funtion language

From: Date: Thu, 12 Feb 2004 02:32:06 +0000
Subject: Re: date() funtion language
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-177469@lists.php.net to get a copy of this message
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 i had problems with locale i think its safer to make a dayname and monthname array, and use getdate(), than build the string yourself like: <? $wdayname_array = array('Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'); $monthname_array = array('Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'); function date_wrapper($format, $timestamp=NULL) { global $wdayname_array, $monthname_array; if ($timestamp == NULL) $timestamp = time(); $date = getdate($timestamp); $wdayname = $wdayname_array[$date['wday']]; $monthname = $monthname_array[$date['mon']-1]; $format = str_replace(array('l', 'F'), array('\\\\\l', '\\\\\F'), $format); $date = date($format, $timestamp); $date = str_replace(array('\\l', '\\F'), array($wdayname, $monthname), $date); return $date; } echo date_wrapper('l, d \de F \de Y'); //the follow should, but doesnt seem to work //setlocale(LC_ALL, 'pt_BR'); //echo date('l, j de F de Y'); ?> this example may not work well with slashes... just wrote it hehe tb sou brasileiro hehe (im brazillian too) Thiago Pavesi wrote: | Hello, | | Does any one knows how do I set my date() function to return the days | of the week and moth in my own language (brazilian portuguese)? | | Thanks, | | Thiago Pavesi -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFAKuWmaxdA/5C8vH8RAv7gAJ0WHvXC4beywQDTjQzz7KI0jLGfPACgjqgv y/UzSg9ijyRx/UvWGi8dFXU= =Wh2S -----END PGP SIGNATURE-----

« previous php.general (#177469) next »