PHP
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<form action="" method="POST">
|
||||
<h2>Filtrado entre fechas</h2>
|
||||
<div style="display: flex; flex-direction:column; width:fit-content; gap:1rem">
|
||||
<input type="date" name="fechaIni" id="fechaIni">
|
||||
<input type="date" name="fechaFin" id="fechaFin">
|
||||
<input type="submit" value="Enviar">
|
||||
</div>
|
||||
<br>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$fechaIni = strtotime($_POST['fechaIni']);
|
||||
$fechaFin = strtotime($_POST['fechaFin']);
|
||||
|
||||
$separador = "/_/";
|
||||
$nombre_archivo = "listado_clientes.txt";
|
||||
$archivo = fopen($nombre_archivo, 'r');
|
||||
|
||||
while (($linea = fgets($archivo)) !== false) {
|
||||
$contenido_linea = explode("/_/", $linea);
|
||||
$tiempo = $contenido_linea[0];
|
||||
$tiempo = intval(substr($tiempo, 0, strpos($tiempo, '_')));
|
||||
|
||||
if ($tiempo >= $fechaIni && $tiempo <= $fechaFin) {
|
||||
echo "Cliente: $contenido_linea[1] - $contenido_linea[2] <br>";
|
||||
}
|
||||
}
|
||||
fclose($nombre_archivo);
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user