Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Ejercicio 8</title>
- </head>
- <body>
- <?php
- if (!$_POST) {
- ?>
- <form action="ejercicio9.php" method="post">
- <label for=num1 >Introduce tu fecha de nacimiento ej: 1996-02-25 <input type="text" id="campo1" name="campo1"/></label><br><br>
- <input type="submit" value="Enviar"/>
- </form>
- <?php
- } else {
- $date = $_POST['campo1'];
- $data_actual = date("y-m-d");
- $datetime1 = date_create($date);
- $datetime2 = date_create($data_actual);
- $interval = date_diff($datetime1, $datetime2);
- echo $interval->format('%y años');
- echo "<br>";
- echo $interval->format('%m meses');
- echo "<br>";
- echo $interval->format('%d dias');
- echo "<br>";
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement