RE: [PHP-ES] Fecha

From: Date: Mon, 12 Mar 2001 09:40:05 +0000
Subject: RE: [PHP-ES] Fecha
References: 1  Groups: php.general.es 
Request: Send a blank email to general-es+get-7878@lists.php.net to get a copy of this message
Hola, Aqui te van dos funciones hechas por mi, para fechas en formato largo y corto: // Get the long date/time function getLongDateTime($optional_timestamp = "") { // Set spanish locale setlocale("LC_TIME", "es_ES"); 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", "es_ES"); 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 la funcion de "setlocale" puedes cambiar el parametro por el local que tu servidor tenga en español. A mi me funciona el locale que esta puesto en los ejemplos: "es_ES". Ademas como puedes notar ambas funciones tienen un parametro opcional para poner un timestamp, sino pones el timestamp coje la fecha actual. Buena suerte, Omar Rosado > -----Original Message----- > From: Edgardo Rossetto [mailto:erossetto@sinectis.com.ar] > Sent: Monday, March 12, 2001 3:39 AM > To: lista@phpes.com > Subject: [PHP-ES] Fecha > > > Hola: > > Alguien me puede enviar una función que me muestre el día de la semana, el > mes y el año? > > No entiendo la explicación del manual. > > Saludos > > Edgardo > > > --------------------------------------------------------------------- > 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 (#7878) next »