Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/05/2014, 22:37
quico5
 
Fecha de Ingreso: enero-2008
Mensajes: 580
Antigüedad: 16 años, 3 meses
Puntos: 9
Fechas en PHP con posible formato incorrecto

creo que es un problema en mi PHP: envió la fecha a la base de datos pero esta no se guarda ¿la estoy mandando mal desde PHP? gracias

Código:
$fecha = "2014-13-12"; se guarda en la en MYSQL cómo 0000-00-00
Lo uso para pasar la fecha de español a ingles
Código PHP:
implode("-"array_reverse(explode("-"$fecha))) 
Código PHP:
        public function insertarNoticia($titulo$noticia$fecha) {
            
$fecha implode("-"array_reverse(explode("-"$fecha)));
            
$this->_db->prepare(
                
"INSERT INTO noticias VALUES (null, :titulo, :noticia, :fecha)"
            
)->execute(array(':titulo' => $titulo':noticia' => $noticia':fecha' => $fecha));
        }

        public function 
editarNoticia($id$titulo$noticia$fecha)    {
            
$id = (int) $id;
            
$fecha implode("-"array_reverse(explode("-"$fecha)));
            
$this->_db->prepare(
                
"UPDATE noticias SET titulo = :titulo, noticia = :noticia, fecha = :fecha WHERE id = :id"
            
)->execute(array(':id' => $id':titulo' => $titulo':noticia' => $noticia':fecha' => $fecha));
        }