<?php
function Diferenca($hora1, $hora2=""){
if($hora2==""){
$hora2 = date("H:i:s");
}
for($i=1;$i<=2;$i++){
${"horas".$i} = substr(${"hora".$i},0,2);
${"minutos".$i} = substr(${"hora".$i},3,2);
${"segundos".$i} = substr(${"hora".$i},6,2);
}
$dia = date(d);
$mes = date(m);
$ano = date(Y);
$segundos = mktime($horas2,$minutos2,$segundos2,$mes,$dia,$ano)-mktime($horas1,$minutos1,$segundos1,$mes,$dia,$ano);
return date("H:i:s",mktime(0,0,$segundos,$mes,$dia,$ano));
}
echo "<a href='index.php'>voltar</a><br />";
//echo "<a href='exportar.php'>exportar</a><br />";
//echo "<a href='exportar2.php'>exportar2</a><br />";
echo "<a href='exportar3.php'>exportar</a><br />";
//$id = $_SESSION['username']
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my", $con);
$result = mysql_query("SELECT * FROM Persons");
//DATEDIFF(entra, sai) as diferenca FROM
//SELECT campos, DATEDIFF(entra, sai) as diferenca FROM...
//$result2 = mysql_query("SELECT DATEDIFF(entra, sai) FROM persons");
$data1 = $row['entra'];
$data2 = $row['sai'];
//$datadif = echo datediff('$sai', '$entra');
//chamamos a função e imprimimos
//echo calcular_tempo_trasnc($entra, $sai);
echo "<table border='0' style='background-color:#F2B600'>
<tr>
<th>nome</th>
<th>dia</th>
<th>mes</th>
<th>ano</th>
<th>turno</th>
<th>entra</th>
<th>sai</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr style='background-color:#FFFF66'>";
echo "<td>" . $row['nome'] . "</td>";
echo "<td>" . $row['dia'] . "</td>";
echo "<td>" . $row['mes'] . "</td>";
echo "<td>" . $row['ano'] . "</td>";
echo "<td>" . $row['turno'] . "</td>";
echo "<td>" . $row['entra'] . "</td>";
echo "<td>" . $row['sai'] . "</td>";
echo "<td>" . Diferenca($data1,$data2) . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>

Ainda N Consegui A Diferença De Horas
Started By Wallace Locus, 22/01/2009, 17:12
2 replies to this topic
1 user(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)