Re: date en español

From: Date: Wed, 13 Dec 2000 01:09:56 +0000
Subject: Re: date en español
References: 1  Groups: php.general.es 
Request: Send a blank email to general-es+get-4884@lists.php.net to get a copy of this message
Nunca pense que fuera tan largo, gracias... en el manual no tenía ejemplos en el manual. Saludos ----- Original Message ----- From: "Omar Rosado" <omar@deaqui.com> To: <lista@phpes.com> Sent: Tuesday, December 12, 2000 6:02 PM Subject: RE: [PHP-ES] date en español > > Alguien tiene una clase o función para mostrar el día, mes, año > > en español? > > ¿Te refieres a que exprese la fecha textualmente o mediante un calendario? > > Si es textualmente lo puedes lograr facilmente asi: > > // Get the long date/time > function getLongDateTime($optional_timestamp = "") > { > // Set spanish locale > setlocale("LC_TIME", "Spanish_Puerto Rico.1252"); // For Windows > setlocale("LC_TIME", "es_ES.ISO_8859-1"); // For FreeBSD > > if($optional_timestamp == "") > { > $current_weekday = ucfirst(strftime("%A")); > $current_monthday = date("j"); > $current_month = strtolower(strftime("%B")); > $current_year = date("Y"); > $current_time = date("g:i:s A"); > } > else > { > $optional_timestamp = strtotime($optional_timestamp); > $current_weekday = ucfirst(strftime("%A", $optional_timestamp)); > $current_monthday = date("j", $optional_timestamp); > $current_month = strtolower(strftime("%B", $optional_timestamp)); > $current_year = date("Y", $optional_timestamp); > $current_time = date("g:i:s A", $optional_timestamp); > } > $current_date_time = $current_weekday . ", "; > $current_date_time .= $current_monthday . " de " . $current_month . " de " > . $current_year; > $current_date_time .= " (" . $current_time . ")"; > > return($current_date_time); > } > > // Get the short date/time > function getShortDateTime($optional_timestamp = "") > { > // Set spanish locale > setlocale("LC_TIME", "Spanish_Puerto Rico.1252"); // For Windows > setlocale("LC_TIME", "es_ES.ISO_8859-1"); // For FreeBSD > > if($optional_timestamp == "") > { > $current_monthday = date("j"); > $current_month = strftime("%m"); > $current_year = date("Y"); > $current_time = date("g:i A"); > } > else > { > $optional_timestamp = strtotime($optional_timestamp); > $current_monthday = date("j", $optional_timestamp); > $current_month = strftime("%m", $optional_timestamp); > $current_year = date("Y", $optional_timestamp); > $current_time = date("g:i A", $optional_timestamp); > } > $current_date_time = $current_month . "-" . $current_monthday . "-" . > $current_year; > $current_date_time .= "-" . $current_time; > > return($current_date_time); > } > > En ambas funciones quizas tendras que jugar un rato con el LOCALE de tu > servidor de PHP en especifico pues puede variar. Como puedes ver en ambas > funciones tengo para Windows o FreeBSD. En otros O/S de Unix usualmente > encuentras los LOCALES disponibles en "/usr/lib/locale" y puedes buscar el > lenguaje que deseas. > > Si quieres un clase para un calendario en español, existen varias por ahi > pero varian muchisimo en su estilo visual. Yo coji una clase en ingles y la > converti a español usando el mismo metodo descrito arriba. Si quieres la que > yo "transforme" a español me avisas, y te puedo ayudar. > > Saludos, > Omar Rosado > > > --------------------------------------------------------------------- > Archivo On-line: http://www.phpes.com/ > Manual PHP en español: http://www.php.net/manual/es/ > Para dar de baja la suscripción, mande un mensaje a: > lista-unsubscribe@phpes.com > >

« previous php.general.es (#4884) next »