/***** Para insertar en la BD, en Formato AM o PM ****/
function update_time($hora){
$a;
$b;
// recibo las horas en formato am, pm
// calculo la longitut de la cadena recibida
$long=strlen($hora);
for ($i=0; $i<$long; $i++) {
if($hora[$i]==""){
$hora[$i]=6;
break;
}
if ($hora[$i]=='a' or $hora[$i]=='p') {
$a=$i;
}
if ($hora[$i]=='m') {
$b=$i;
}
}
/*Obtiene am o pm, segun se mando en el formulario*/
$ap = $hora[$a].$hora[$b];
$ttt = explode(":", $hora);
$th = $ttt['0'];
$tm = $ttt['1'];
if($ap=='pm' || $ap=='PM'){
$th+=12;
if($th==24){
$th = 12;
}
}
if($ap=='am' || $ap=='AM'){
if($th==12){
$th = '00';
}
}
$newtime = $th.":".$tm[0].$tm[1];
return $newtime;
}
$hora = update_time($_POST['hora']);
$AgregaHora="INSERT INTO tabla (hora)VALUES('$hora')";