TEMA : calcular tiempo en semanas - Foro de Tu Informática Fácil

TEMA : calcular tiempo en semanas

calcular tiempo en semanas 18 Nov 2011, 03:37 #38

  • luis
  • Avatar de luis
  • DESCONECTADO
  • Karma:

calcular tiempo en semanas

Tengo un formulario llamado lote. En el formulario hay un campo en el que se introduce la fecha mediante un calendario. Necesito que cuando se realice la consulta, aparezca en un campo llamado edad actual, el tiempo en semanas a partir de la fecha que se introdujo en el formulario. Tengo un codigo en el extraer de lote que permite hacer el calculo pero a la hora de hacer la consulta, no da el numero de semanas correcto, y el sistema presenta tres comentarios sobre tres lineas de codigo de la funcion . Les adjunto el codigo del extraer de lote.

 

ver_lote.php

 

function Semanas($fecha_desde, $fecha_hasta){ $divide_ini = explode("-", $fecha_desde); $divide_fin = explode("-", $fecha_hasta); $fecha_ini = mktime(0, 0, $divide_ini[0], $divide_ini[1], $divide_ini[2]); $fecha_fin = mktime(0, 0, $divide_fin[0], $divide_fin[1], $divide_fin[2]); $segundos = $fecha_ini - $fecha_fin; // Obtenemos los segundos entre esas dos fechas $segundos = abs($segundos); //en caso de errores $semanas = floor($segundos / 604800); //Obtenemos las semanas entre esas fechas. echo "Hay " . $semanas; } //include("conecta.php");$conectar=mysql_connect("localhost","root","sena");mysql_select_db("tecnoavicola19",$conectar); //$resultado = mysql_query("SELECT * FROM lote ORDER BY id_lote"); $_pagi_sql =("SELECT * FROM lote ORDER BY id_lote"); //cantidad de resultados por página (opcional, por defecto 20)$_pagi_cuantos = 3; //Incluimos el script de paginación. Éste ya ejecuta la consulta automáticamenteinclude("paginator.inc.php"); echo "<table width='100%' height='100%' border='' bgcolor=''> <tr bgcolor='#5F9EA0'><td>NRO. LOTE</td><td>FECHA INGRESO</td><td>NUMERO AVES</td><td>LINEAS</td><td>EDAD FECHA INGRESO</td><td>OBSERVACIONES</td><td>SEMANAS</td></tr>"; //while($fila = mysql_fetch_array($resultado))while($fila = mysql_fetch_array($_pagi_result)){echo "<tr> <td>" . $fila . "</td> <td>" . $fila . "</td> <td>" . $fila . "</td> <td>" . $fila . "</td> <td>" . $fila . "</td> <td>" . $fila . "</td> <td>"; $fecha_actual = date(m-d-Y); Semanas($fila,$fecha_actual); echo "</td> </tr>"; }//Incluimos la barra de navegaciónecho"<p>".$_pagi_navegacion."</p>"; echo "</table>";mysql_close($conectar);?> <p align="center" HEIGHT="5%" width="18%" ><input id="registro" name="Imprimir" type="button" value="imprimir" style='cursor:pointer' onClick="window.print()"></p>

 

Al hacer la consulta, en el campo semanas, que es donde debe aparecer el cálculo, aparece este mensaje del sistema:

 

Strict Standards: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for '-5.0/no DST' instead in C:\AppServ\www\tecnoavicola_AppServer1\modelos\ver_lote.php on line 46

 

Este corresponde a esta linea de codigo:

<td>";$fecha_actual = date(m-d-Y); Semanas($fila['fch_ingreso'],$fecha_actual);echo "</td>

 

Strict Standards: mktime() [function.mktime]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for '-5.0/no DST' instead in C:\AppServ\www\tecnoavicola_AppServer1\modelos\ver_lote.php on line 8

 

Este corresponde a esta linea de còdigo:

$fecha_ini = mktime(0, 0, $divide_ini[0], $divide_ini[1], $divide_ini[2]);

 

Strict Standards: mktime() [function.mktime]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the time zone identifier. We selected 'America/New_York' for '-5.0/no DST' instead in C:\AppServ\www\tecnoavicola_AppServer1\modelos\ver_lote.php on line 9

 

Este corresponde a esta línea de código: $fecha_fin = mktime(0, 0, $divide_fin[0], $divide_fin[1], $divide_fin[2]);

 

Por favor lean el código y espero me aconsejen algo. Gracias.

😎

Conectados

Total de usuarios conectados 221 :: 0 Miembro(s) y 221 invitado(s).
Leyenda:  Administrador del Sitio Moderador Global Moderador Sancionado Usuario Invitado

Estadísticas

Total de mensajes : 379 | Total temas : 145 | Total miembros : 37533
Nuestro nuevo miembro : coro1959
JDL Forum