Ver Mensaje Individual
  #15 (permalink)  
Antiguo 10/06/2011, 11:05
Avatar de memoadian
memoadian
Colaborador
 
Fecha de Ingreso: junio-2009
Ubicación: <?php echo 'México'?>
Mensajes: 3.696
Antigüedad: 15 años, 7 meses
Puntos: 641
Respuesta: Obtener fecha en formato español DD:MM:AAAA

a ver

Código PHP:
Ver original
  1. <?php
  2. $sql_fecha = "select fecha from reserva;";
  3. $result = mysql_query($sql_fecha) or die("nada de nada");
  4.  
  5. function fechaesp($date) {
  6.     $dia = explode("-", $date, 3);
  7.     $year = $dia[0];
  8.     $month = (string) (int) $dia[1];
  9.     $day = (string) (int) $dia[2];
  10.     $dias = array("dom", "lun", "mar", "mi&eacute;r", "jue", "vie", "s&aacute;b");
  11.     $tomadia = $dias[intval((date("w", mktime(0, 0, 0, $month, $day, $year))))];
  12.     $meses = array("", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre");
  13.     return $tomadia . ", " . $day . " de " . $meses[$month] . " de " . $year;
  14. }
  15.  
  16. while ($registro = mysql_fetch_array($result)) {
  17.     $date = $registro['fecha'];
  18.     echo fechaesp($date);
  19. }
  20. ?>