0
I would like to limit the result of while. My code displays the number of days between two dates correctly, but I would like the result (no while) to be showing the dates every 30 days, as if each line was a month, to facilitate counting.
Ex:
01-01-2017, 02-01-2017, ... completed 30 days enter
01-01-2017, 02-01-2017, ... completed 30 days enter
01-01-2017, 02-01-2017, ... completed 30 days enter
Just follow my code
<?php
include "exibe_ico.php";
if (empty($_POST['data_inicial']) or empty($_POST['data_final']) ) { echo "<script> window.alert('Preencha a data!'); history.back(); </script>"; exit(); }
ValidaData($_POST['data_inicial']);
ValidaData($_POST['data_final']);
$data_inicial = $_POST['data_inicial'];
$data_final = $_POST['data_final'];
function geraTimestamp($data) {
$partes = explode('/', $data);
return mktime(0, 0, 0, $partes[1], $partes[0], $partes[2]);
}
$time_inicial = geraTimestamp($data_inicial);
$time_final = geraTimestamp($data_final);
$diferenca = $time_final - $time_inicial; // 19522800 segundos
$dias = ((int)floor( $diferenca / (60 * 60 * 24))+1); // 225 dias
echo "<table border='1' width=80%>";
echo "<tr>";
echo "<th>Início</th>";
echo "<th>Fim</th>";
echo "<th>Nº dias</th>";
echo "</tr>";
echo "<tr>";
echo "<td align='center'>$data_inicial</td>";
echo "<td align='center'>$data_final</td>";
echo "<td align='center'>$dias</td>";
echo "</tr>";
echo "</table>";
echo "<p><div align=left><a href='dias.php?acao=entrar'><< Voltar</a></font></div>";
?>
<?php
$Dias = 0;
$contagem = 1;
$enter = 1;
$result = date("d-m-Y", strtotime(str_replace('/', '-', $data_inicial)));
while($Dias < $dias)
{
echo "
<table>
<tr>
<td width=60 align='center'>{$contagem}º dia</td>
<td width=100 align='center'>"; echo date("d-m-Y", strtotime("+ $Dias days",strtotime($result))); echo "</td>
</tr>
</table>
";
$Dias++;
$contagem++;
}
Ask a question correctly, tell how the date format is in the bank, and in the example all 3 lines are equal, you would like an answer with the same coin of your question?
– user60252