Ver Mensaje Individual
  #1  
Antiguo 29-09-2007
Avatar de tazzmk
tazzmk tazzmk is offline
Miembro
 
Registrado: sep 2007
Posts: 45
Reputación: 0
tazzmk Va por buen camino
convertir fechas php

hola porfavor

como puedo hacer ingresar este formato de fecha a mysql
dd/mm/aaaa

ejemplo:
14/10/2007

en que me abre equivocado? tengo duda si abre ingreso bien o no la llamada de la funcion en $query="insert into tabla (fecha)values('fecha_mysql($fecha)')";

ya que cuando ingreso siempre me sale 0000-00-00

uso el localhost de appserv

saludos

Código PHP:
<?
function fecha_mysql($fecha)
{
    
ereg"([0-9]{1,2})/([0-9]{1,2})/([0-9]{2,4})"$fecha$mifecha);
    
$fecha_lista=$mifecha[3]."-".$mifecha[2]."-".$mifecha[1];
    return 
$fecha_lista;
}
?>

<?
if(isset($enviar)) {
$dab=mysql_connect("localhost","","");
mysql_select_db("fecha",$dab);
$query="insert into tabla (fecha)values('fecha_mysql($fecha)')";
$res=mysql_query($query,$dab);
}
?>

<form method="post" action="inicio.php">
  ingrese fecha: 
  <input name="fecha" type="text" size="10" maxlength="10">
  <br>
  <br>
  <input type="submit" name="enviar" value="Enviar">
</form>
Responder Con Cita