RE: [PHP-ES] date en español

From: Date: Tue, 12 Dec 2000 21:02:10 +0000
Subject: RE: [PHP-ES] date en español
References: 1  Groups: php.general.es 
Request: Send a blank email to general-es+get-4879@lists.php.net to get a copy of this message
> 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

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