Re: Sobre fecha

From: Date: Sat, 20 Dec 2003 00:56:56 +0000
Subject: Re: Sobre fecha
References: 1  Groups: php.general.es 
Request: Send a blank email to general-es+get-43874@lists.php.net to get a copy of this message
Yo utilizo este codigo "tomado de OSCommerce" y adaptado a mis requerimientos Funciona muy bien y es totalmente integral para utilizar en muchas situaciones diferentes . define('DATE_FORMAT_SHORT', '%d/%m/%Y'); // para utilizar con strftime() define('DATE_FORMAT_LONG', '%A %d %B, %Y'); // para utilizar con strftime() define('DATE_FORMAT', 'd/m/Y'); // para utilizar con date() define('DATE_TIME_FORMAT', DATE_FORMAT_SHORT . ' %H:%M:%S'); function tep_date_long($raw_date) { if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false; $year = (int)substr($raw_date, 0, 4); $month = (int)substr($raw_date, 5, 2); $day = (int)substr($raw_date, 8, 2); $hour = (int)substr($raw_date, 11, 2); $minute = (int)substr($raw_date, 14, 2); $second = (int)substr($raw_date, 17, 2); return strftime(DATE_FORMAT_LONG, mktime($hour,$minute,$second,$month,$day,$year)); } function tep_date_short($raw_date) { if ( ($raw_date == '0000-00-00 00:00:00') || empty($raw_date) ) return false; $year = substr($raw_date, 0, 4); $month = (int)substr($raw_date, 5, 2); $day = (int)substr($raw_date, 8, 2); $hour = (int)substr($raw_date, 11, 2); $minute = (int)substr($raw_date, 14, 2); $second = (int)substr($raw_date, 17, 2); if (@date('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) { return date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, $year)); } else { return ereg_replace('2037' . '$', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037))); } } function tep_date_separated($raw_date) { if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false; $arrayd= array('year4' => substr($raw_date, 0, 4), 'year2' => substr($raw_date, 2, 2), 'month' => substr($raw_date, 5, 2) ); return $arrayd; } ----- Original Message ----- From: "Julio Herrera" <jherrera@chilered.com> To: <lista@phpes.com> Sent: Friday, December 19, 2003 4:14 PM Subject: [PHP-ES] Sobre fecha Guardo con date('Y-m-d H:i:s', time()) la fecha de hoy en una base de datos, y los registros quedan asi 2003-12-19 18:46:42 mi problema es presentarlos al usuario de esta forma 19-12-2003, yo se que debe ser super facil pero con 31 grados de calor y con una pelea con el jefe, mas los clientes llamando, no puedo ni encontrar la solucion, trate de usar strftime pero me pone todas las fechas con el año 1971. Si alguna alma caritativa me puede ayudar Atentamente, Julio Herrera Vega. --------------------------------------------------------------------- Archivo On-line: http://www.phpes.com/ via news: news://news.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 (#43874) next »